There is something I missed to mention here and I
faced while working on migrating the servlet TCK to using
arquillian junit.
And I would like to discuss it.
I will take this class as example
com.sun.ts.tests.servlet.api.jakarta_servlet.servletrequest.URLClient.
The current TCK is using some javadoc annotations such:
/*
* @testName: getAttributeNamesTest
*
* @assertion_ids: Servlet:JAVADOC:174
*
* @test_Strategy: Servlet sets some attributes and
verifies they can be
* retrieved.
*
*/
The class doesn't have this method but it's inherited.
The current framework will run only the methods found
with the javadoc annotations @testName (the method could be
in the current class or inherited)
Per default, junit runs only tests with the
annotation @Test and will run all annotated methods in
inherited classes which we don't want here.
I have marked all test methods with @Test in parent
classes but by default all inherited classes will run
all @Test methods which is wrong.
But @Test annotation is very convenient for running a
test in any IDE.
What I did currently is to write a maven plugin [1] which
parses sources and finds javadoc annotation @testName to
generate a text file containing all the className#methodName
to run.
Then I wrote a
dedicated org.junit.platform.engine.TestEngine [2] which
read the generated files from parsing sources to run only
those tests.
It works but I find this extra work and a bit more
complicated to configure in Maven (and more maintenance in
case junit changes something).
My idea was to simply add the missing methods to the
classes such
in com.sun.ts.tests.servlet.api.jakarta_servlet.servletrequest.URLClient
(this can be done by the same plugin which is currently
parsing the classes to discover which tests to run)