[jbosstools-dev] Should we use @Ignore in non-runnable JUnit test classes, instead of <include> in pom? (was: JUnit Tests)

Max Rydahl Andersen max.andersen at redhat.com
Fri Jan 23 06:42:35 EST 2015


So this always been one of the things I disliked about our parent pom. I 
much rather prefer run all the test classes automatically.

The reason for the current pattern is historically - that most tests 
were done via testsuites instead of individual ones since there was no 
other good way of grouping tests.

Problem is we haven't found a good way of moving from the old to the new 
without having to go through all the existing test code and ensure the 
tests are not double executed.

But right now I think the only one I know that is pro-testsuites being 
the default is Rob S. who have just
said he is fine switching to Tests being executed by default - he can 
just use the TestSuite pattern in his test projects if he insists :)

One drawback of not having testsuites is though that we loose the 
ability to easily run a group of tests from eclipse or maven.

Anyone found a good way of doing that via junit ? (testng has groups but 
tycho surefire/junit does not support that afaik)

That said - i'm all for looking at moving to this for Mars builds.

I guess the suggestion is to:

  exclude *Abstract*, *Suite* and only include *Test.class, correct ? 
(Xavier used *TestCase.class which is a different pattern than the rest 
afaics)

PR welcome on 
https://github.com/jbosstools/jbosstools-build/blob/master/parent/pom.xml


> What about using <excludes> to ignore the Abstract*.class and other 
> similar classes [1] ?
> I don't use any TestSuite class in the JAX-RS tooling component 
> ofJBoss Tools, because I think it's an unnecessary pain to have to 
> maintain an extra/accurate list of all the test classes that need to 
> be run. And I like that some test methods or even test classes can be 
> skipped with the @Ignore annotation.
>
> [1] Here's what I have in my pom.xml:
>
>   <plugin>
>   <groupId>org.eclipse.tycho</groupId>
>   <artifactId>tycho-surefire-plugin</artifactId>
>   <configuration>
>     <includes>
>       <include>**/*TestCase.class</include>
>     </includes>
>     <excludes>
>       <exclude>**/Abstract*.class</exclude>
>     </excludes>
>   </configuration>
> </plugin>	
>
> Best regards,
> /Xavier
>
>
>
>> On 22 Jan 2015, at 20:51, Nick Boldt <nboldt at redhat.com> wrote:
>>
>> No, because then AbstractTest* and TemplateTest* classes would run, 
>> and
>> they shouldn't be.
>>
>> You can set your own <include> entries in your root pom. Then all 
>> your
>> projects' tests will inherit those new rules.
>>
>> --
>>
>> We may also have some older JUnit 3 tests (from the JDK 1.4 era?) 
>> that
>> might still be set to run with older JRE environments, where
>> @annotations are not supported.
>>
>> If I'm wrong on that, and we no longer support running tests w/ old
>> runtimes, then yes, we could consider adding @Ignores to all the 
>> tests
>> which shouldn't be run, instead of using the "All" and "Suite" naming
>> conventions.
>>
>> --
>>
>> I've cc:'d the jbosstools-dev list because a wider audience might be
>> able to comment better on if it's time to move to using @ignore 
>> instead
>> of using restrictive patterns when running JUnits w/ Surefire in
>> Tycho/Maven builds.
>>
>> N
>>
>> On 01/22/2015 02:08 PM, Daniel Florian wrote:
>>> Guys,
>>>
>>> We currently have to add each JUnit test class to a test suite file 
>>> called AllTests.java. If a test does not get added to this test 
>>> suite it does not get run.
>>>
>>> I think the pom has this:
>>>
>>> <includes>
>>>           <include>**/AllTests.class</include>
>>>           <include>**/*AllTests*.class</include>
>>>           <include>**/*AllBotTests*.class</include>
>>>           <include>**/*TestSuite*.class</include>
>>> </includes>
>>>
>>> Could we add:
>>>
>>>           <include>**/Test*.class</include>
>>>           <include>**/*Test.class</include>
>>>
>>> So that we wouldn't need an AllTests.java. Other projects can keep 
>>> using the test suite approach.
>>>
>>> With JUnit's @Ignore it is easy to stop a test from being run.
>>>
>>> wdyt?
>>>
>>> Thanks,
>>>
>>> Dan
>>>
>>
>> -- 
>> Nick Boldt :: JBoss by Red Hat
>> Productization Lead :: JBoss Tools & Dev Studio
>> http://nick.divbyzero.com
>> _______________________________________________
>> jbosstools-dev mailing list
>> jbosstools-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jbosstools-dev


/max
http://about.me/maxandersen


More information about the jbosstools-dev mailing list