Null pointer exception only with groups

1,472 views
Skip to first unread message

kebmo

unread,
Oct 28, 2009, 12:09:54 PM10/28/09
to testng-users
Just getting started with TestNG, and also with Selenium. When I
enable a groups block in my suite file, my test dies in my code on the
first line of the (only) test. When I disable the groups block, the
test is run and completes successfully. I'm using TestNG 5.10 (also
tried 5.8 and whatever comes bundled with IntelliJ IDEA 8.1.3) with
latest Java 5. I first noticed the problem in the IDEA environment,
but I've since reproduced it outside of IDEA.

Thanks for letting me know what I'm doing wrong.

-Murph

I provide the test suite file, the stack output, and the test source
code below.

TEST SUITE FILE

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Custom suite" parallel="none" verbose="10">
<parameter name="selenium.url" value="http://localhost:8080/">
</parameter>
<parameter name="selenium.browser" value="*safari">
</parameter>
<parameter name="verbose" value="10">
</parameter>
<test verbose="10" name="cnv" annotations="JDK">
<!-- comment out the <groups> block, and this suite/test works -->
<groups>
<run>
<include name="selenium"/>
</run>
</groups>
<classes>
<class name="test.TestCase1"/>
</classes>
</test>
</suite>

STACK OUTPUT

java.lang.NullPointerException
at test.TestCase1.testTestCase1(TestCase1.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod
(MethodHelper.java:607)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:517)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:
669)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:
956)
at org.testng.internal.TestMethodWorker.invokeTestMethods
(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run
(TestMethodWorker.java:110)
at org.testng.TestRunner.runWorkers(TestRunner.java:759)
at org.testng.TestRunner.privateRun(TestRunner.java:592)
at org.testng.TestRunner.run(TestRunner.java:486)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:
327)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
at org.testng.SuiteRunner.run(SuiteRunner.java:204)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:867)
at org.testng.TestNG.runSuitesLocally(TestNG.java:832)
at org.testng.TestNG.run(TestNG.java:748)
at org.testng.TestNG.privateMain(TestNG.java:904)
at org.testng.TestNG.main(TestNG.java:877)

TEST SOURCE CODE

package test;

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;

import java.util.regex.Pattern;

public class TestCase1 extends SeleneseTestNgHelper {
@Test(groups = { "selenium" })
public void testTestCase1() throws Exception {
selenium.open("/Search");
selenium.waitForPageToLoad("30000");
selenium.type("ui=searchPage::position()",
"chr1:742429-758311");
selenium.click("ui=searchPage::submitButton()");
selenium.waitForPageToLoad("30000");
//selenium.captureEntirePageScreenshot("/tmp/snap.png", "");
// See if the Sample column is present
String maybeSample = selenium.getText("xpath=//table
[@id='resultlist']/thead/tr[2]/th[3]/span");
assertTrue(selenium.isTextPresent("regexp:1 to [1-9][0-9]* of
[1-9][0-9]* non-unique CNVs (from [0-9]+ samples* )*from the
Normals_CHOP source located at chr1:742429-758311"));
if (maybeSample.equals("Sample")) {
//id('resultlist')/thead/tr[2]/th[11]/span
assertTrue(Pattern.compile("[1-9][0-9]*").matcher
(selenium.getTable("resultlist.2.11")).find());
} else {
assertTrue(Pattern.compile("[1-9][0-9]*").matcher
(selenium.getTable("resultlist.2.10")).find());
}
selenium.click("ui=allPages::searchTab()");
selenium.waitForPageToLoad("30000");
selenium.type("ui=searchPage::position()",
"chr1:5547116-5548075");
selenium.click("ui=searchPage::submitButton()");
selenium.waitForPageToLoad("30000");
maybeSample = selenium.getText("xpath=//table
[@id='resultlist']/thead/tr[2]/th[3]/span");
if (maybeSample.equals("Sample")) {
assertEquals(selenium.getTable("resultlist.2.11"),
"<D0>");
} else {
assertEquals(selenium.getTable("resultlist.2.10"),
"<D0>");
}
}
}

VERBOSE TEST CONSOLE OUTPUT

*** CONSOLE LOG ***
[Parser] Running:
/Users/schnebtron/Library/Caches/IntelliJIDEA8x/temp-testng-
customsuite.xml

[TestRunner] Running the tests in 'cnv' with parallel mode:none
[RunInfo] Adding method selector:
org.testng.internal.XmlMethodSelector@bc92535 priority: 10
[TestClass] Creating TestClass for [ClassImpl test.TestCase1]
[TestClass] Adding method test.TestCase1.testTestCase1() on TestClass
class test.TestCase1
[XmlMethodSelector] Including group : selenium
[XmlMethodSelector] Excluding method
com.thoughtworks.selenium.attachScreenshotListener()
[XmlMethodSelector] Excluding method com.thoughtworks.selenium.setUp()
[XmlMethodSelector] Excluding method
com.thoughtworks.selenium.getSelenium()
[XmlMethodSelector] Excluding method
com.thoughtworks.selenium.setTestContext()
[XmlMethodSelector] Excluding method
com.thoughtworks.selenium.checkForVerificationErrors()
[XmlMethodSelector] Including method test.testTestCase1()
[SuiteRunner] Created 1 TestRunners
[TestRunner] Running test cnv on 1 classes, included groups:
[selenium ] excluded groups:[]
[TestClass]
======
TESTCLASS: test.TestCase1
[TestClass] Test : test.TestCase1.testTestCase1()
[TestClass] AfterMethod :
com.thoughtworks.selenium.SeleneseTestNgHelper.selectDefaultWindow()
[TestClass]
======

[TestRunner] Found 1 applicable methods
[TestRunner] WILL BE RUN IN RANDOM ORDER:
[TestRunner] test.TestCase1.testTestCase1()
[TestRunner] on instances
[TestRunner] test.TestCase1@5557c2bd
[TestRunner] ===
[Invoker 1875244867] Keeping method
com.thoughtworks.selenium.SeleneseTestNgHelper.selectDefaultWindow()
for class [TestClass class test.TestCase1]
[Invoker 1875244867] Invoking test.TestCase1.testTestCase1
[Invoker 1875244867] Keeping method
com.thoughtworks.selenium.SeleneseTestNgHelper.selectDefaultWindow()
for class [TestClass class test.TestCase1]
[Invoker 1875244867] Invoking @AfterMethod
com.thoughtworks.selenium.SeleneseTestNgHelper.selectDefaultWindow()
[Invoker 1875244867] Invoking @AfterTest
com.thoughtworks.selenium.SeleneseTestNgHelper.tearDown()

*********** INVOKED METHODS

test.TestCase1.testTestCase1() 1431814845

***********

Creating /Users/schnebtron/tmp/test-output/Custom suite/cnv.html
Creating /Users/schnebtron/tmp/test-output/Custom suite/cnv.xml
FAILED: testTestCase1
java.lang.NullPointerException
at test.TestCase1.testTestCase1(TestCase1.java:12)
... Removed 22 stack frames

===============================================
cnv
Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Custom suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

Cédric Beust ♔

unread,
Oct 28, 2009, 12:16:18 PM10/28/09
to testng...@googlegroups.com
The exception seems to be happening in your code:

java.lang.NullPointerException
at test.TestCase1.testTestCase1(TestCase1.java:12)

Where is your `selenium` field initialized?

--
Cédric

kebmo

unread,
Oct 28, 2009, 1:01:55 PM10/28/09
to testng-users
On Oct 28, 12:16 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> The exception seems to be happening in your code:
> java.lang.NullPointerException
> at test.TestCase1.testTestCase1(TestCase1.java:12)
>
> Where is your `selenium` field initialized?

The superclass SelaneseTestNgHelper has a setUp method, which invokes
the setUp method of SelaneseTestBase, which initializes the 'selenium'
field.

SelaneseTestNgHelper::setUp is never invoked in the case where I
provide a <groups> block.

Here's the call stack right before the 'selenium' field is initialized
during a successful run:

at com.thoughtworks.selenium.SeleneseTestNgHelper.setUp
(SeleneseTestNgHelper.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0
(NativeMethodAccessorImpl.java:-1)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:
607)
at org.testng.internal.Invoker.invokeConfigurationMethod
(Invoker.java:417)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:
154)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:
88)
at org.testng.TestRunner.beforeRun(TestRunner.java:510)
at org.testng.TestRunner.run(TestRunner.java:478)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
at org.testng.SuiteRunner.run(SuiteRunner.java:204)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:867)
at org.testng.TestNG.runSuitesLocally(TestNG.java:832)
at org.testng.TestNG.run(TestNG.java:748)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)

Cédric Beust ♔

unread,
Oct 28, 2009, 1:04:16 PM10/28/09
to testng...@googlegroups.com
Did you annotate your setUp method with a @Before* annotation?

--
Cédric

kebmo

unread,
Oct 28, 2009, 1:31:39 PM10/28/09
to testng-users
On Oct 28, 1:04 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Did you annotate your setUp method with a @Before* annotation?

(Remember that the same TestNG test suite executes the test absolutely
fine without the <groups> block. It doesn't just succeed trivially,
either -- it really runs the test.)

The folks behind Selenium annotated the setUp method in my test's
superclass:

@BeforeTest
@Override
@Parameters({"selenium.url", "selenium.browser"})
public void setUp(@Optional String url, @Optional String
browserString) throws Exception {
if (browserString == null) browserString = runtimeBrowserString
();
super.setUp(url, browserString);
staticSelenium = selenium;
};

I'm a bit of a Java duffer, but I ran the failing test configuration
and turned on CPU tracing with VisualVM. In "good" stack trace, I
don't see org.testng.TestRunner.beforeRun(TestRunner.java:510) ever
call org.testng.internal.Invoker.invokeConfigurations(Invoker.java:
88).

I've determined that the IntelliJ TestNG-J plugin uses TestNG 5.6, but
I don't know how to step into the TestNG source code when I run the
test in debugging mode. (Yes, I'm also an IntelliJ duffer).

kebmo

unread,
Oct 28, 2009, 1:36:07 PM10/28/09
to testng-users
On Oct 28, 1:31 pm, kebmo <murphy2atnet...@gmail.com> wrote:
> I've determined that the IntelliJ TestNG-J plugin uses TestNG 5.6

Actually, that may not be true. I was looking at the external plugin
description, but I'm using whatever is bundled by default with
IntelliJ IDEA 8.1.3.

Cédric Beust ♔

unread,
Oct 28, 2009, 1:38:11 PM10/28/09
to testng...@googlegroups.com
On Wed, Oct 28, 2009 at 10:31 AM, kebmo <murphy2...@gmail.com> wrote:

On Oct 28, 1:04 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Did you annotate your setUp method with a @Before* annotation?

(Remember that the same TestNG test suite executes the test absolutely
fine without the <groups> block.  It doesn't just succeed trivially,
either -- it really runs the test.)

The folks behind Selenium annotated the setUp method in my test's
superclass:

   @BeforeTest
   @Override 
   @Parameters({"selenium.url", "selenium.browser"})
   public void setUp(@Optional String url, @Optional String browserString) throws Exception {
 

You need to put that method in the group you're running ("selenium") or it won't get run.

Also, are you sure you want @BeforeTest and not @BeforeMethod?

--
Cédric


kebmo

unread,
Oct 28, 2009, 4:34:49 PM10/28/09
to testng-users
On Oct 28, 1:38 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> > The folks behind Selenium annotated the setUp method in my test's
> > superclass:
> >    @BeforeTest
> >    @Override
>    @Parameters({"selenium.url", "selenium.browser"})
> >    public void setUp(@Optional String url, @Optional String browserString)
>
> You need to put that method in the group you're running ("selenium") or it
> won't get run.

Aha, thanks!

Naively, that seems surprising to me; I would expect setUp to always
be called.

Would @AlwaysRun also be a possibility? Either that, or since
SelaneseTestNgHelper is part of an open source framework, maybe its
setUp method should get its own documented group.

In the meantime, I guess I can override setUp in my subclass of
SelaneseTestNgHelper and declare that with the appropriate group (or
put my entire class in the group, right?)

> Also, are you sure you want @BeforeTest and not @BeforeMethod?

Hopefully the authors of SelaneseTestNgHelper know what they're doing,
but I don't know. The documentation sucks. How would I choose? Are
you concerned about concurrency? I can define my own setUp method
overriding that of the superclass and apply whatever annotation I
like.

Thanks again!

Cédric Beust ♔

unread,
Oct 28, 2009, 4:38:43 PM10/28/09
to testng...@googlegroups.com
On Wed, Oct 28, 2009 at 1:34 PM, kebmo <murphy2...@gmail.com> wrote:

On Oct 28, 1:38 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> > The folks behind Selenium annotated the setUp method in my test's
> > superclass:
> >    @BeforeTest
> >    @Override
>    @Parameters({"selenium.url", "selenium.browser"})
> >    public void setUp(@Optional String url, @Optional String browserString)
>
> You need to put that method in the group you're running ("selenium") or it
> won't get run.

Aha, thanks!

Naively, that seems surprising to me; I would expect setUp to always
be called.

Would @AlwaysRun also be a possibility?  Either that, or since
SelaneseTestNgHelper is part of an open source framework, maybe its
setUp method should get its own documented group.

In the meantime, I guess I can override setUp in my subclass of
SelaneseTestNgHelper and declare that with the appropriate group (or
put my entire class in the group, right?)

You can use alwaysTrue=true if you want it to always be run, but by default, configuration methods obey group rules just like test methods.
 

> Also, are you sure you want @BeforeTest and not @BeforeMethod?

Hopefully the authors of SelaneseTestNgHelper know what they're doing,
but I don't know.  The documentation sucks.

The TestNG documentation?  I thought the difference between @BeforeTest and @BeforeMethod is clearly documented there...

--
Cédric


kebmo

unread,
Oct 28, 2009, 8:58:44 PM10/28/09
to testng-users
On Oct 28, 4:38 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> On Wed, Oct 28, 2009 at 1:34 PM, kebmo <murphy2atnet...@gmail.com> wrote:
> > but I don't know.  The documentation sucks.
>
> The TestNG documentation?  I thought the difference between @BeforeTest and
> @BeforeMethod is clearly documented there...

Cédric, no, the TestNG documentation is great. On the other hand, the
Selenium documentation leaves a lot to be desired.

-Kevin

Pratik Jaiswal

unread,
Aug 3, 2015, 10:21:47 AM8/3/15
to testng-users, murphy2...@gmail.com
Hi there,
I am getting the error as:

/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7532 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 14 CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA 14 CE.app/Contents/plugins/testng/lib/testng-plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/jpratik/IdeaProjects/MyFirstAppiumProject/out/production/MyFirstAppiumProject:/Users/jpratik/Downloads/java-client-3.1.0.jar:/Users/jpratik/Downloads/selenium-server-standalone-2.47.1.jar:/Applications/IntelliJ IDEA 14 CE.app/Contents/plugins/testng/lib/testng.jar:/Applications/IntelliJ IDEA 14 CE.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.testng.RemoteTestNGStarter -port 59579 -usedefaultlisteners false -socket59580 -temp /private/var/folders/h8/wvqxc9fs4mx9c3v8b91kng4m0000gn/T/idea_testng13.tmp
[TestNG] Running:
  /Users/jpratik/Library/Caches/IdeaIC14/temp-testng-customsuite.xml

java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
at org.openqa.selenium.support.ui.FluentWait.<init>(FluentWait.java:95)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:71)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:45)
at MyAppTest.invalidCredentialsTest(MyAppTest.java:44)

Process finished with exit code 0



My code:

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.MobileDriver;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.net.URL;

/**
* Created by jpratik on 8/1/15.
*/
public class MyAppTest {

private String validname = "pratik";
private String validpass = "jaiswal";
private String validtext = "Yes, I am the navigated one!";

AppiumDriver driver;

@Before
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("deviceName", "AndroidTestDevice");

driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
}

@After
public void tearDown() throws Exception{
driver.quit();
}

@Test
public void invalidCredentialsTest(){

WebElement enternamebox = (new WebDriverWait(driver, 60))
.until(ExpectedConditions.presenceOfElementLocated(By.id("com.loginapp.app:id/editText")));
enternamebox.sendKeys(validname);

WebElement enterpassbox = driver.findElement(By.id("com.loginapp.app:id/editText2"));
enterpassbox.sendKeys(validpass);

WebElement loginclick = driver.findElement(By.id("com.loginapp.app:id/button"));
loginclick.click();

WebElement activitytext2 = (new WebDriverWait(driver, 60))
.until(ExpectedConditions.presenceOfElementLocated(By.id("com.loginapp.app:id/yay")));

Assert.assertEquals(activitytext2.getText(), validtext);
}
}



Any help would be really appreciated.

Krishnan Mahadevan

unread,
Aug 3, 2015, 10:32:17 AM8/3/15
to testng...@googlegroups.com
As I mentioned in the other thread, the problem is in your test code. Please use TestNG configuration annotations in your test code and try again.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Julian Kolodzey

unread,
Apr 5, 2019, 9:49:19 AM4/5/19
to testng-users
@Pratik Jaiswal, you are using annotations from two different frameworks.
TestNG's @Test 
and 
JUnit's @Before and @After. 
Сonsider which framework You are really needed and use its annotations.

There is possible to use both frameworks. In that case, create separate preconditions and postconditions for each of them.

Best regards.
Julian.

Aman Bhalla

unread,
Jan 23, 2020, 4:48:21 AM1/23/20
to testng-users
Yes by assigning the group name to all the parameters like BeforeClass etc it resolved the problem.

@BeforeClass(groups ={"group1", "group2"} )

@Test(groups ={"group1"})
@Test(groups ={"group2"})


@AfterClass(groups ={"group1", "group2"} )

Hemil Turakhia

unread,
Mar 26, 2020, 3:22:21 AM3/26/20
to testng-users
Hey, can you post the code refinement that you did? I am stuck with the same exception when I try to run the selenium group from TestNG XML, I get NPE for the driver. Without including groups to my TestNG XML, it runs perfectly fine. What changes did you make in your code to call the driver?
Reply all
Reply to author
Forward
0 new messages