Null pointer exception only with groups

View: New views
10 Messages — Rating Filter:   Alert me  

Null pointer exception only with groups

by kebmo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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
===============================================

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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




On Wed, Oct 28, 2009 at 9:09 AM, kebmo <murphy2atnetaxs@...> wrote:

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
===============================================






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by kebmo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 28, 12:16 pm, Cédric Beust ♔ <cbe...@...> 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)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did you annotate your setUp method with a @Before* annotation?

--
Cédric



On Wed, Oct 28, 2009 at 10:01 AM, kebmo <murphy2atnetaxs@...> wrote:

On Oct 28, 12:16 pm, Cédric Beust ♔ <cbe...@...> 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)






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by kebmo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 28, 1:04 pm, Cédric Beust ♔ <cbe...@...> 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).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by kebmo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 28, 1:31 pm, kebmo <murphy2atnet...@...> 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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Wed, Oct 28, 2009 at 10:31 AM, kebmo <murphy2atnetaxs@...> wrote:

On Oct 28, 1:04 pm, Cédric Beust ♔ <cbe...@...> 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



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by kebmo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 28, 1:38 pm, Cédric Beust ♔ <cbe...@...> 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!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Wed, Oct 28, 2009 at 1:34 PM, kebmo <murphy2atnetaxs@...> wrote:

On Oct 28, 1:38 pm, Cédric Beust ♔ <cbe...@...> 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



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Null pointer exception only with groups

by kebmo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 28, 4:38 pm, Cédric Beust ♔ <cbe...@...> wrote:
> On Wed, Oct 28, 2009 at 1:34 PM, kebmo <murphy2atnet...@...> 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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---