Problem - test runs methods that aren't part of group

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem - test runs methods that aren't part of group

tarun3kumar
Hi all,

I'm trying to run a specific group of tests but having a problem - TestNG is running *all* the methods in the class despite the fact that I select only a certain group.

I'm using TestNG-5.5 with the Eclipse plugin.

I've created a simple class that has three methods like so:
package foo;
import org.testng.Assert;
import org.testng.annotations.Test;

@Test
public class SimpleTest {
         
        @Test(groups = { "simple" })
        public void doSimpleTest(){
                Assert.assertEquals(getOne(), 1);
        }
       
        @Test(groups = { "simple" })
        public void doSimpleFailure(){
                Assert.assertEquals(getOne(), 2);
        }
       
        @Test(groups={"complex"})
        public void doComplexTest(){
                System.out.println("Howdy");
                Assert.assertFalse(false);
        }

        private int getOne(){return new Integer(1);}
               
}

When I choose to run only the "simple" group (see attached screenshot), all three tests are run despite the fact that the doComplexTest method does not belong to that group.

Following is the xml config that is generated:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="mostTestNG by groups">
  <test verbose="2" name="G:simple" annotations="JDK">
    <classes>
      <class name="foo.SimpleTest"/>
    </classes>
  </test>
</suite>

The output of the test is as follows:
[Parser] Running:
  C:\source\mostTestNG\temp-testng-customsuite.xml

Howdy
PASSED: doSimpleTest
PASSED: doComplexTest
FAILED: doSimpleFailure
java.lang.AssertionError: expected:<2> but was:<1>
        at com.wholefoods.most.SimpleTest.doSimpleFailure(SimpleTest.java:17)
... Removed 26 stack frames

===============================================
    G:simple
    Tests run: 3, Failures: 1, Skips: 0
===============================================


===============================================
mostTestNG by groups
Total tests run: 3, Failures: 1, Skips: 0
===============================================

Any ideas why the xml and output recognize the simple group but it runs methods that don't belong to that group anyway?

Thanks,
G
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=65997&messageID=125973#125973

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


screen.jpg (58K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem - test runs methods that aren't part of group

Alexandru Popescu ☀

Can you please remove the top @Test annotation and try it again?

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 2/21/07, GojiraDeMonstah <[hidden email]> wrote:

> Hi all,
>
> I'm trying to run a specific group of tests but having a problem - TestNG is running *all* the methods in the class despite the fact that I select only a certain group.
>
> I'm using TestNG-5.5 with the Eclipse plugin.
>
> I've created a simple class that has three methods like so:
> package foo;
> import org.testng.Assert;
> import org.testng.annotations.Test;
>
> @Test
> public class SimpleTest {
>
>         @Test(groups = { "simple" })
>         public void doSimpleTest(){
>                 Assert.assertEquals(getOne(), 1);
>         }
>
>         @Test(groups = { "simple" })
>         public void doSimpleFailure(){
>                 Assert.assertEquals(getOne(), 2);
>         }
>
>         @Test(groups={"complex"})
>         public void doComplexTest(){
>                 System.out.println("Howdy");
>                 Assert.assertFalse(false);
>         }
>
>         private int getOne(){return new Integer(1);}
>
> }
>
> When I choose to run only the "simple" group (see attached screenshot), all three tests are run despite the fact that the doComplexTest method does not belong to that group.
>
> Following is the xml config that is generated:
> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
> <suite name="mostTestNG by groups">
>   <test verbose="2" name="G:simple" annotations="JDK">
>     <classes>
>       <class name="foo.SimpleTest"/>
>     </classes>
>   </test>
> </suite>
>
> The output of the test is as follows:
> [Parser] Running:
>   C:\source\mostTestNG\temp-testng-customsuite.xml
>
> Howdy
> PASSED: doSimpleTest
> PASSED: doComplexTest
> FAILED: doSimpleFailure
> java.lang.AssertionError: expected:<2> but was:<1>
>         at com.wholefoods.most.SimpleTest.doSimpleFailure(SimpleTest.java:17)
> ... Removed 26 stack frames
>
> ===============================================
>     G:simple
>     Tests run: 3, Failures: 1, Skips: 0
> ===============================================
>
>
> ===============================================
> mostTestNG by groups
> Total tests run: 3, Failures: 1, Skips: 0
> ===============================================
>
> Any ideas why the xml and output recognize the simple group but it runs methods that don't belong to that group anyway?
>
> Thanks,
> G
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=65997&messageID=125973#125973
>
> >
>
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Problem - test runs methods that aren't part of

tarun3kumar

I've removed the top @Test annotation and get the same behavior.

In the meantime I've done some experimentation - if I manually adjust the xml file it works as expected (changes in [b]bold[/b]):
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="mostTestNG by groups">
  <test verbose="2" name="G:simple" annotations="JDK">
[b] <groups>
    <run>
      <include name="simple"/>
    </run>
  </groups>[/b]
  <classes>
  <class name="foo.SimpleTest"/>
  </classes>
  </test>
</suite>

So it appears that the problem is in how the plugin generates the xml file. I tried creating a new configuration, going out to the file system and deleting the temp-testng-customsuite.xml file, and a few other things but the result is the same.

G
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=65997&messageID=125986#125986


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

Reply | Threaded
Open this post in threaded view
|

Re: Problem - test runs methods that aren't part of

Alexandru Popescu ☀

Thanks a lot for the report G. I will further investigate the issue
and keep you posted.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 2/21/07, GojiraDeMonstah <[hidden email]> wrote:

>
> I've removed the top @Test annotation and get the same behavior.
>
> In the meantime I've done some experimentation - if I manually adjust the xml file it works as expected (changes in [b]bold[/b]):
> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
> <suite name="mostTestNG by groups">
>   <test verbose="2" name="G:simple" annotations="JDK">
> [b]      <groups>
>         <run>
>                 <include name="simple"/>
>         </run>
>   </groups>[/b]
>   <classes>
>                 <class name="foo.SimpleTest"/>
>   </classes>
>   </test>
> </suite>
>
> So it appears that the problem is in how the plugin generates the xml file. I tried creating a new configuration, going out to the file system and deleting the temp-testng-customsuite.xml file, and a few other things but the result is the same.
>
> G
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=65997&messageID=125986#125986
>
>
> >
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Problem - test runs methods that aren't part of

Alexandru Popescu ☀
Hi!

I think I have found a stupid typo that was causing the error. You can
use the attached class  to patch the plugin (replace it in your
eclipse-testng.jar).

Please let me know if it works for you.

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator


On 2/21/07, Alexandru Popescu <[hidden email]> wrote:

> Thanks a lot for the report G. I will further investigate the issue
> and keep you posted.
>
> ./alex
> --
> .w( the_mindstorm )p.
>   TestNG co-founder
> EclipseTestNG Creator
>
>
> On 2/21/07, GojiraDeMonstah <[hidden email]> wrote:
> >
> > I've removed the top @Test annotation and get the same behavior.
> >
> > In the meantime I've done some experimentation - if I manually adjust the xml file it works as expected (changes in [b]bold[/b]):
> > <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
> > <suite name="mostTestNG by groups">
> >   <test verbose="2" name="G:simple" annotations="JDK">
> > [b]      <groups>
> >         <run>
> >                 <include name="simple"/>
> >         </run>
> >   </groups>[/b]
> >   <classes>
> >                 <class name="foo.SimpleTest"/>
> >   </classes>
> >   </test>
> > </suite>
> >
> > So it appears that the problem is in how the plugin generates the xml file. I tried creating a new configuration, going out to the file system and deleting the temp-testng-customsuite.xml file, and a few other things but the result is the same.
> >
> > G
> > ---------------------------------------------------------------------
> > Posted via Jive Forums
> > http://forums.opensymphony.com/thread.jspa?threadID=65997&messageID=125986#125986
> >
> >
> > > >
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


CustomSuite.class (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem - test runs methods that aren't part of

tarun3kumar

Alex,

That fixed it for me. Fantastic! Thanks!

G
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=65997&messageID=126169#126169


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