相关疑难解决方法(0)

如何将(JUnit)测试套件导出为可执行jar

在eclipse(Helios)中是否有办法将我的JUnit测试套件(或者甚至可能的测试用例)打包/导出为可执行的jar?

我知道如何从具有主类的项目生成可运行的jar,但我对如何包含a无能为力TestRunner.
有一种直截了当的方式,还是我必须制作一个解决方法主类调用TestRunner某种方式?

细节会很棒.

java eclipse junit unit-testing jar

34
推荐指数
1
解决办法
3万
查看次数

如何在maven-shade-plugin创建的Jar中包含测试类?

我正在尝试使用Maven将我的测试类打包到一个带有依赖项的可执行jar中,但我很难做到这一点.

到目前为止这是我的pom.xml:

<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.c0deattack</groupId>
    <artifactId>executable-tests</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>executable-tests</name>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.21.0</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>cucumber-tests</finalName>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>cucumber.cli.Main</mainClass>
                                </transformer>
                            </transformers>
                            <artifactSet>
                                <includes>
                                    <include>info.cukes:*</include>
                                </includes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.c0deattack</groupId>
                        <artifactId>executable-tests</artifactId>
                        <version>1.0</version>
                        <type>test-jar</type>
                    </dependency>
                </dependencies>
            </plugin> …
Run Code Online (Sandbox Code Playgroud)

java dependencies maven maven-jar-plugin maven-shade-plugin

30
推荐指数
2
解决办法
2万
查看次数