[PJUG Javamail] TestNG issues with JDK 1.4/Junit

Lyle T. Harris lyle.harris at gmail.com
Sun Jul 19 00:53:11 EDT 2009


How about creating a class that extends your JUnit test class
and then overriding the tests that fail into a no-op method call?

public class TestWrapper extends TestNG_Junit {

    public void testfalse() {
       // No-op
    }

}

<test name="Test1" junit="true">

  <classes>

    <class name="TestWrapper">

  </classes>

</test>




Bullard, Douglas wrote:
>
> Yes, it looks like the include/exclude stuff doesn't work at all if 
> you've told it it's JUnit stuff... Since we have to run it in JUnit 
> mode ('cause of the Spring issues with JKD 1.4), we'll have to 
> surround "bad" methods with a boolean test or something so that 
> they're still there, just not run with a flag.  Tedious, but that's 
> what we get for never upgrading (as I keep telling my management, the 
> workarounds for not upgrading are costing us more time than just 
> upgrading).
>
>  
>
> Thanks,
>
>  
>
> Doug
>
>  
>
> ------------------------------------------------------------------------
>
> *From:* Lyle.Harris at Sun.COM [mailto:Lyle.Harris at Sun.COM] *On Behalf Of 
> *Lyle T. Harris
> *Sent:* Friday, July 17, 2009 11:21 AM
> *To:* Bullard, Douglas
> *Cc:* Javamail at pjug.org
> *Subject:* Re: [PJUG Javamail] TestNG issues with JDK 1.4/Junit
>
>  
>
> Not sure if this will work but have you tried including
> and excluding by method name?  If this works, you
> wouldn't even need to edit your existing JUnit code.
>
> <test name="Test1">
>   <classes>
>     <class name="example1.Test1">
>       <methods>
>         <include name=".*enabledTestMethod.*"/>
>         <exclude name=".*brokenTestMethod.*"/>
>       </methods>
>      </class>
>   </classes>
> </test>
>
>
>
> Bullard, Douglas wrote:
>
> Hope someone can help us out on this...
>
>  
>
> We've got some old, old projects JDK 1.4 with tons of failing unit 
> tests.  The best thing to do would be to fix the broken unit tests, 
> but that's out of scope.
>
>  
>
> A possible partial solution would be to convert to TestNG -- and tell 
> it to run in JUnit mode.  Problem is, when you do that, you can't mark 
> tests in groups and only run the "good" ones.
>
>  
>
> To make matters worse, we're using Spring (usually a good thing), and 
> have tests which extend Spring's base test classes.  Running those in 
> TestNG (not in JUnit mode, so we can turn off bad tests) fails.  The 
> old version of Spring is 2.0, and 2.5 added Spring functionality for 
> TestNG (and we can't upgrade on these projects).
>
>  
>
> Anybody know of a way to get TestNG to be able to run and ignore tests 
> in JUnit mode?
>
>  
>
> Here is a sample class. We want to run the first two tests (that pass) 
> and skip the last test (that is known to fail, hence the group) 
> WITHOUT adding testng tags to the tests that pass.
>
>  
>
> Anybody have any ideas?  We've posted to the TestNG forums, but we're 
> trying to figure this out before the weekend...
>
>  
>
> Thanks in advance...
>
>  
>
>  
>
> Douglas Bullard
>
>  
>
>  
>
> Here's a sample class
>
>  
>
> public class TestNG_Junit extends TestCase
> {
> public void testtrue()
> {
> assertTrue(true);
> }
> public void testDoubleFalse()
> {
> assertFalse(false);
> }
> /**
> * @testng.test groups = "failed"
> */
> public void testfalse()
> {
> assertTrue(false);
> }
> }
>
>  
>
> Here's the testng.xml file:
>
>  
>
> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" 
> <http://testng.org/testng-1.0.dtd>>
>
> <suite name="Generated Suite">
>
>   <test verbose="1" name="dummy tests" annotations="javadoc"
>
>         junit="true">
>
>     <groups>
>
>       <run>
>
>           <exclude name="failed"  />
>
>       </run>
>
>     </groups>
>
>     <packages>
>
>       <package name="*"/>
>
>     </packages>
>
>   </test>
>
> </suite>
>
>  
>
>
> ------------------------------------------------------------------------
>
>
>  
> _______________________________________________
> Web Site - http://www.pjug.org/
> Javamail mailing list
> Javamail at pjug.org <mailto:Javamail at pjug.org>
> http://www.pjug.org/mailman/listinfo/javamail
>   
>
>  
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Web Site - http://www.pjug.org/
> Javamail mailing list
> Javamail at pjug.org
> http://www.pjug.org/mailman/listinfo/javamail
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pjug.org/pipermail/javamail/attachments/20090718/074da363/attachment.html 


More information about the Javamail mailing list