eclipse-tycho / tycho

Tycho project repository (tycho)
https://tycho.eclipseprojects.io
Eclipse Public License 2.0
166 stars 189 forks source link

tycho-surefire-plugin does not find junit5 suite #1097

Open carstenartur opened 2 years ago

carstenartur commented 2 years ago

You can see what I mean looking at the pull request at https://github.com/eclipse-jdt/eclipse.jdt.ui/pull/129 It contains a suite like this:

@SelectPackages({"org.eclipse.jdt.internal.common"})
@Suite
public class JUnit5TestSuite {

}

The pom file contains

<build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        <version>${tycho.version}</version>
        <configuration>
          <useUIHarness>true</useUIHarness>
          <useUIThread>true</useUIThread>
          <includes>
            <!--<include>org/eclipse/jdt/ui/tests/AutomatedSuite.class</include>-->
            <include>org/eclipse/jdt/internal/common/JUnit5TestSuite.class</include>
             <!--<include>org/eclipse/jdt/ui/tests/LeakTestSuite.class</include> -->
          </includes>
          <dependencies>
            <dependency>
              <type>eclipse-plugin</type>
              <artifactId>org.eclipse.equinox.event</artifactId>
              <version>0.0.0</version>
            </dependency>
          </dependencies>
          <argLine>${leakTestsArgLine}</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>

Unfortunately tycho does not find the junit5 suite. As soon as I exchange the entry with the (single) junit5 test class VisitorTest it works fine.

laeubi commented 2 years ago

@carstenartur can you provide an integration-test to demonstrate the issue?

carstenartur commented 2 years ago

I just tried to setup eclipse for tycho development but just have ran into an error: image maybe there has been some github migration and it is not finished? image At least the oomph setup seems to be pointing to the no longer existing gerrit based git repositories unless I'm not mistaken...

laeubi commented 2 years ago

@carstenartur you can setup an example project first, and import only the itest-project, you don't need a full IDE setup.

carstenartur commented 2 years ago

Tbh currently I think it would be more useful in this concrete case to find out how I can run the tests in the jdt.ui pull request without tycho. So the question is how I can mix - everything else running through tycho and some new tests using surefire directly. It looks like this is much faster. But I will try something to extract the issue into a sample project as soon as I find some time. Thanks so far!

laeubi commented 2 years ago

Tbh currently I think it would be more useful in this concrete case to find out how I can run the tests in the jdt.ui pull request without tycho.

No one forces you to run them with Tycho :-)

So the question is how I can mix - everything else running through tycho and some new tests using surefire directly.

Simply use eclipse-plugin as packaging and configure maven-surefire as you like.

Bananeweizen commented 2 years ago

Might this be just a naming problem? Your Suite name does not match any of the default include patterns: https://www.eclipse.org/tycho/sitedocs/tycho-surefire-plugin/test-mojo.html#includes

carstenartur commented 2 years ago

Might this be just a naming problem? Your Suite name does not match any of the default include patterns: https://www.eclipse.org/tycho/sitedocs/tycho-surefire-plugin/test-mojo.html#includes

You mean the explicit directive does not help? Hm, something to test. It looks like in the documentation you mentioned the construct used in jdt.ui is not described

Bananeweizen commented 2 years ago

The include configuration takes Java source names, not class file names. But besides that I really recommend naming suites no different than other tests. I've run into the issue of non-execution because of not being named FooTest or TestFoo way too often in multiple tools already.

carstenartur commented 2 years ago

Here you see some documentation that claims default pattern is using ".class" ending. I guess what is needed is an option to make the search patterns applied visible in the log. It is just too intransparent what is going on otherwise. https://www.eclipse.org/tycho/sitedocs/tycho-surefire-plugin/plugin-info.html However, it could easily be that I'm completely wrong. I did not check the sourcecode.

davu-all commented 1 year ago

Hi I am experiencing the same problem. I am trying to run my tests on Tycho 4.0.0 with the tycho-surefire-plugin. It recognises the junit5 test classes but if i specify in the "includes" parameter only the junit5 testsuites then it says that no tests have been found.