eclipse / Xpect

This repository has been rewritten to move to the Eclipse Foundation. Find the old history here: https://github.com/TypeFox/Xpect
http://www.xpect-tests.org/
Eclipse Public License 2.0
32 stars 28 forks source link

No tests found #165

Closed toshovski closed 9 years ago

toshovski commented 9 years ago

So I tried to run the Xpect tests with tycho. As basis I used the pom file from org.eclipse.xtext.example.domainmodel.xpect.tests, but there are no tests found. Here is my pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <version>1.0.0-SNAPSHOT</version>
        <groupId>org.company</groupId>
        <artifactId>parent</artifactId>
        <relativePath>../org.company.parent</relativePath>
    </parent>
    <artifactId>org.company.dsl.xpect.tests</artifactId>
    <packaging>eclipse-test-plugin</packaging>

    <properties>
        <os-jvm-flags />
        <memory-settings>-Xmx1G</memory-settings>
        <tycho-version>0.21.0</tycho-version>
    </properties>

    <profiles>
        <profile>
            <id>macosx-jvm-flags</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <os-jvm-flags>-XstartOnFirstThread</os-jvm-flags>
            </properties>
        </profile>
    </profiles>

    <build>
        <!-- make sure surefire finds our test classes even though they are in 
            the "src" folder -->
        <testOutputDirectory>target/classes</testOutputDirectory>

        <plugins>

            <!-- use tycho -->
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho-version}</version>
                <extensions>true</extensions>
            </plugin>

            <!-- Use maven surefire (not tycho surefire!) to run tests as plain JUnit 
                tests (not Plug-In JUnit tests!) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surfire-reports-standalone</reportsDirectory>
                </configuration>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.16</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-surefire-plugin</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surfire-reports-plugin</reportsDirectory>
                    <useUIHarness>true</useUIHarness>
                    <useUIThread>false</useUIThread>
                    <argLine>${memory-settings} ${os-jvm-flags}</argLine>
                    <dependencies>
                        <dependency>
                            <type>eclipse-plugin</type>
                            <artifactId>org.eclipse.xtext.logging</artifactId>
                        </dependency>
                    </dependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

My Xpect Test Runner:

package  org.company.dsl.xpect.tests;
import org.junit.runner.RunWith;
import org.xpect.runner.XpectRunner;
import org.xpect.xtext.lib.tests.XtextTests;

@RunWith(XpectRunner.class)
public class MyXpectTests extends XtextTests {

}

And the simple test

/* XPECT_SETUP org.company.dsl.xpect.tests.MyXpectTests END_SETUP */
polymorph sss {
    // XPECT errors --> "Couldn't resolve reference to Structure 'Kunde'." at "Kunde"
    structures {Kunde}
    // XPECT errors --> "Couldn't resolve reference to Element 'abc'."
    fields {abc}
}

When I call xpect in maven with -X, i get the following error message:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test (default-test) on project de.abas.erp.satz.editor.dsl.xpect.tests: No tests found. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test (default-test) on project de.abas.erp.satz.editor.dsl.xpect.tests: No tests found.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: No tests found.
    at org.eclipse.tycho.surefire.TestMojo.runTest(TestMojo.java:908)
    at org.eclipse.tycho.surefire.TestMojo.execute(TestMojo.java:625)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
meysholdt commented 9 years ago

The name of your Java test class is probably not matched by surefire's inclusion filter. see: http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

It should work if you rename MyXpectTests to MyXpectTest (remove the trailing "s"). Or, alternatively, configure the element for your two surefire Maven plugins.

toshovski commented 9 years ago

You are right! That was the problem. The example on the Xpect webpage has the same name. Maybe you should change it.

Thanks for the quick answer.

meysholdt commented 9 years ago

true, I should change it.