Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven tycho surefire插件失败,返回代码13_Maven_Tycho_Tycho Surefire Plugin - Fatal编程技术网

Maven tycho surefire插件失败,返回代码13

Maven tycho surefire插件失败,返回代码13,maven,tycho,tycho-surefire-plugin,Maven,Tycho,Tycho Surefire Plugin,我有一个OSGI包,现在想为它创建一个测试包。由于现有的bundle使用了Tycho,我还想通过使用Tycho-surefire插件来测试Eclipse/Tycho 据我所知,测试Eclipse方式意味着每个包都有一个包含所有相关测试用例的对应包 因此,我使用以下pom创建了一个新的捆绑包“xyz.tests”: <artifactId>xyz.tests</artifactId> <packaging>eclipse-test-plugin&

我有一个OSGI包,现在想为它创建一个测试包。由于现有的bundle使用了Tycho,我还想通过使用Tycho-surefire插件来测试Eclipse/Tycho

据我所知,测试Eclipse方式意味着每个包都有一个包含所有相关测试用例的对应包

因此,我使用以下pom创建了一个新的捆绑包“xyz.tests”:

    <artifactId>xyz.tests</artifactId>
    <packaging>eclipse-test-plugin</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-surefire-plugin</artifactId>
                <version>0.21.0</version>
            </plugin>
        </plugins>
    </build>
构建属性

output.. = bin/
source.. = src/
bin.includes = META-INF/,\
           OSGI-INF/,\
           .
# META-INF/MANIFEST.MF
Bundle-Name=XYZ Tests
和OSGI-INF/l10n/bundle.properties

output.. = bin/
source.. = src/
bin.includes = META-INF/,\
           OSGI-INF/,\
           .
# META-INF/MANIFEST.MF
Bundle-Name=XYZ Tests
然后我写了一个“测试用例”,因为我第一次想检查我的eclipse测试插件是否配置正确

package xyz.tests.xyz;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

public class XYZTest {

    @Test
    public void testClasstest() {
        assertEquals("Tests", true, true);
    }
}
当我以运行mvn包为目标时,所有的编译和包都不会出错。然后我以运行mvn集成测试为目标(这是tycho surefire开始工作的部分)。在那里,我收到一条错误消息,它没有为我提供任何有用的信息:

[INFO] --- tycho-surefire-plugin:0.21.0:test (default-test) @ xyz.tests ---
[INFO] Expected eclipse log file: /pathXYZ/target/work/data/.metadata/.log
[INFO] Command line:
    [/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java, -Dosgi.noShutdown=false, -Dosgi.os=linux, -Dosgi.ws=gtk, -Dosgi.arch=x86_64, -Dosgi.clean=true, -jar, /home/erdi/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.3.0.v20130327-1440/org.eclipse.equinox.launcher-1.3.0.v20130327-1440.jar, -data, /pathXYZ/target/work/data, -install, /pathXYZ/target/work, -configuration, /pathXYZ/target/work/configuration, -application, org.eclipse.tycho.surefire.osgibooter.headlesstest, -testproperties, /pathXYZ/target/surefire.properties]
xyz: Hello World!!

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
xyz: Goodbye World!!
An error has occurred. See the log file
/pathXYZ/target/work/configuration/1432736234573.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.050s
[INFO] Finished at: Wed May 27 16:17:16 CEST 2015
[INFO] Final Memory: 69M/362M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test (default-test) on project xyz.tests: An unexpected error occured (return code 13). See log for details. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
“xyz:Hello/debye World”消息是我想要测试的包启动/停止时打印的消息。这意味着,当bundle启动时,我的配置似乎是正常的,但在启动后立即出现错误。不幸的是,查看日志文件也没有发现任何有用的信息:

!SESSION 2015-05-27 16:17:14.238 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_75
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /pathXYZ/target/work/data -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties /pathXYZ/target/surefire.properties

!ENTRY org.eclipse.osgi 4 0 2015-05-27 16:17:15.891
!MESSAGE Application error
!STACK 1
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:123)
    at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:87)
    at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NullPointerException
    at java.lang.Class.getAnnotation(Class.java:3217)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:63)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:52)
    at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:80)
    at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:174)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:83)
    ... 28 more
所以我知道会发生空指针异常,但我不知道为什么/在哪里

我认为看到隐藏在“…28更多”后面的整个错误路径真的很有帮助,但我不知道如何看到它


我也不完全确定是否正确配置了所有内容,因为我没有找到有用的教程,并且或多或少地查看了其他eclipse项目的测试代码库。

我终于找到了问题的根源:

我使用的是tycho v0.21.0,该问题被报告为bug(),并通过tycho v0.22.0得到修复

更改tycho surefire插件的version属性解决了此问题