Bug 453526 - Improve error message if Testsuite but not Testclass is specified in pom.xml
Summary: Improve error message if Testsuite but not Testclass is specified in pom.xml
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jan Sievers CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed, helpwanted
Depends on:
Blocks:
 
Reported: 2014-11-28 08:09 EST by Lars Vogel CLA
Modified: 2021-04-28 16:51 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2014-11-28 08:09:16 EST
If I want to configure Tycho to run a test suite I need to specify Testsuite and TestClass

This took me relatively long to figure out, the TestSuite is actually the Bundle-Symbolic-Name and the TestClass points to my Test suite.

https://wiki.eclipse.org/Tycho/Reference_Card#Setting_up_the_tests_to_run

Maybe the error message could a bit more helpful? For example instead of:

Both testSuite and testClass must be provided or both should be null.

This one would have helped me:

Both testSuite (pointing to the Bundle-Symbolic-Name) and testClass (pointing to the test class/suite) must be provided or both should be null.

<build>
        <plugins>   
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-surefire-plugin</artifactId>
                <version>${tycho.version}</version>
                <configuration>
                    <testSuite>org.eclipse.e4.ui.tests.css.swt</testSuite>
                    <testClass>org.eclipse.e4.ui.tests.css.swt.CssSwtTestSuite</testClass>
                </configuration>
            </plugin>
        </plugins>
</build>
Comment 1 Jan Sievers CLA 2014-11-28 08:32:30 EST
IMHO testSuite is a misnomer but too late to change the name, it's API

http://eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/test-mojo.html#testSuite

However I'm not sure why it's a must to specify  both the suite test class and bundle-symbolicname of the the test suite class 

why would we not assume that the test suite class can be loaded by the current test bundle if it's not specified explicitly?
Comment 2 Lars Vogel CLA 2014-11-28 08:36:41 EST
(In reply to Jan Sievers from comment #1)
> IMHO testSuite is a misnomer but too late to change the name, it's API

Maybe add a new parameter and deprecated the old one?

> http://eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/test-
> mojo.html#testSuite
> 
> However I'm not sure why it's a must to specify  both the suite test class
> and bundle-symbolicname of the the test suite class 
> why would we not assume that the test suite class can be loaded by the
> current test bundle if it's not specified explicitly?

+1
Comment 3 Martin Schreiber CLA 2014-12-02 07:17:35 EST
The "testSuite" parameter is used to skip maven projects other than the one specified by "testSuite". If you are building e.g. 3 eclipse-test-plugins in one maven session, and want to execute only one test from the 2nd eclipse-test-plugin, the other 2 plugins must be skipped. 
(Executing the oterh 2 plugins would end up in "No Test found" error, since the specified testClass would not be found in the other 2 bundles)

An alternativ might be to only specify the testClass, search for it in the current project and skip execution if it could not be found, but than it could not be distinguished if a testClass could not be found because it is not part of that bundle or it could not be found because the testClass value is wrong.
Comment 4 Jan Sievers CLA 2014-12-02 08:52:47 EST
(In reply to Martin Schreiber from comment #3)
> The "testSuite" parameter is used to skip maven projects other than the one
> specified by "testSuite". If you are building e.g. 3 eclipse-test-plugins in
> one maven session, and want to execute only one test from the 2nd
> eclipse-test-plugin, the other 2 plugins must be skipped. 
> (Executing the oterh 2 plugins would end up in "No Test found" error, since
> the specified testClass would not be found in the other 2 bundles)

I think this is unrelated. Executing a specific test in a multi-module build with multiple test modules can be achieved with

-Dtest=TestClass -DfailIfNoTests=false


Looking at the implementation

http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/tree/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java#n600


I realize the parameter testSuite does not make any sense at all.
The build will always fail if you don't repeat the Bundle-SymbolicName of the current test bundle as testSuite. All it does if check whether you specified the correct Bundle-SymbolicName of the current test module (but it's not used for anything).

So unless I'm mistaken the parameter testSuite can be simply removed without any side-effect.
Comment 5 Martin Schreiber CLA 2014-12-02 09:40:09 EST
(In reply to Jan Sievers from comment #4)
> (In reply to Martin Schreiber from comment #3)
> > The "testSuite" parameter is used to skip maven projects other than the one
> > specified by "testSuite". If you are building e.g. 3 eclipse-test-plugins in
> > one maven session, and want to execute only one test from the 2nd
> > eclipse-test-plugin, the other 2 plugins must be skipped. 
> > (Executing the oterh 2 plugins would end up in "No Test found" error, since
> > the specified testClass would not be found in the other 2 bundles)
> 
> I think this is unrelated. Executing a specific test in a multi-module build
> with multiple test modules can be achieved with
> 
> -Dtest=TestClass -DfailIfNoTests=false
> 

Yes this can also be achieved with that, with one small difference. 
Running 
a) -Dtest=TestClass -DfailIfNoTests=false
and 
b) -DtestSuite=myTestBundleId -DtestClass=foo.bar.TestClass

a) will not fail if no TestClass could be found, b) will.



> 
> Looking at the implementation
> 
> http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/tree/tycho-surefire/
> tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.
> java#n600
> 
> 
> I realize the parameter testSuite does not make any sense at all.
> The build will always fail if you don't repeat the Bundle-SymbolicName of
> the current test bundle as testSuite. All it does if check whether you
> specified the correct Bundle-SymbolicName of the current test module (but
> it's not used for anything).
> 
> So unless I'm mistaken the parameter testSuite can be simply removed without
> any side-effect.

When removing the testSuite parameter, would it make sense to keep the testClass parameter then? As you mentioned, executing a specific test can also be achieved by -Dtest=MyTest?
Comment 6 Lars Vogel CLA 2014-12-02 09:43:29 EST
> When removing the testSuite parameter, would it make sense to keep the
> testClass parameter then? As you mentioned, executing a specific test can
> also be achieved by -Dtest=MyTest?

We should be able to specify the Testclass in the pom.xml, I read this suggestion that it should only be possible via a parameter.
Comment 7 Jan Sievers CLA 2014-12-02 11:41:13 EST
(In reply to Martin Schreiber from comment #5)
> When removing the testSuite parameter, would it make sense to keep the
> testClass parameter then? As you mentioned, executing a specific test can
> also be achieved by -Dtest=MyTest?

no, testClass should be kept for compatibility. 

testSuite has no effect anyway (apart from forcing the user to repeat the BSN of the current test bundle), so we can remove it.
Comment 8 Jan Sievers CLA 2014-12-02 11:46:11 EST
(In reply to Lars Vogel from comment #6)
> > When removing the testSuite parameter, would it make sense to keep the
> > testClass parameter then? As you mentioned, executing a specific test can
> > also be achieved by -Dtest=MyTest?
> 
> We should be able to specify the Testclass in the pom.xml, I read this
> suggestion that it should only be possible via a parameter.

both "testClass" and "test" paramaters have property annotations, that means they can be specified both in pom.xml and/or on CLI, no change here.

In general, mojo parameters can always be specified in pom.xml. You can only add the possibility to specify them on CLI.
Comment 9 Martin Schreiber CLA 2014-12-03 03:27:41 EST
Submitted a patch for review: https://git.eclipse.org/r/37488 
(Removed the testSuite parameter)
Comment 10 Martin Schreiber CLA 2014-12-03 04:07:50 EST
The IT Test TYCHO45Test is failing because it tests a multi bundle build with different test plugins and had specified the testSuite and testClass parameter.
As said, testSuite skipped all the test plugins that did not match the testSuite value.
Now this test is failing because it tries to execute just the test specified in testClass and this could only be found in one test plugin, the others are failing because no test can be found. 
Is it ok to set failIfNoTests=false for that IT Test?