7

How can I run a single plug-in test method in Maven using tycho-surefire-plugin?

I tried the -Dtest option with #, but it doesn't work:

mvn clean install -Dtest=MyUITest#testDummy

Is there something I am missing?

oberlies
  • 11,503
  • 4
  • 63
  • 110

1 Answers1

2

Your question is already answered here.

However you can use TestSuite and Filter to achieve what you want or even more customized selection of tests.

public class FilteredTests extends TestSuite {

public static TestSuite suite() {
    TestSuite suite = new TestSuite();

    suite.addTest(new JUnit4TestAdapter(YourTestClass.class).filter(new Filter() {

            @Override
            public boolean shouldRun(Description description) {
                return description.getMethodName().equals("Your_Method_name");
            }

            @Override
            public String describe() {
                // TODO Auto-generated method stub
                return null;
            }
        }));

    return suite;
}

}

Now configure tycho-surefire plugin to run this suite

<configuration>
                ...
                <testSuite>bundle.symbolic.name.of.test.plugin</testSuite>
                <testClass>package.of.test.suite.FilteredTests</testClass>
                ...
</configuration>
Community
  • 1
  • 1
coder11
  • 457
  • 3
  • 9
  • The accepted solution in the linked question is to use the hash character (`#`) as separator for the method name. According to Prasanth's question this doesn't work. Does it work for you? – oberlies Sep 23 '13 at 13:07
  • I have the same issue, the # does not work for me either. – SeB.Fr Nov 24 '15 at 10:26
  • 2
    Can confirm the hash syntax does not work with the `tycho-surefire-plugin`. I've just resorted to ignoring the other test methods in my class, or moving it to a separate temporary class file and using `-Dtest=` to specify that class file. Frustrating that they don't maintain parity with the standard surefire plugin. – Craig Otis Oct 07 '17 at 19:27
  • 1
    Frustrating indeed: the ${test} property in tycho-surefire only supports classes according to its documentation: https://www.eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/test-mojo.html#test – mat101 Oct 11 '19 at 09:49