当使用tycho-surefire-plugin执行JUnit测试时,tycho会分配一个equinox运行时.在极少数情况下,可能会发生OSGi测试运行时中的某些bundle无法解析/启动(例如,包使用冲突).如果您阅读调试日志(maven CLI选项-X),您会发现类似的内容
!ENTRY org.eclipse.osgi 2 0 2012-10-08 16:41:31.635
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2012-10-08 16:41:31.635
An error has occurred. See the log file
C:\mytestproject.tests\target\work\configuration\1349705136008.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:03.181s
[INFO] Finished at: Mon Oct 08 16:17:16 CEST 2012
[INFO] Final Memory: 20M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.15.0:test (default-test) on project mytestproject.tests: An unexpected error occured (return c
ode 13). See log for details. -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
在程序包使用冲突的情况下,eclipse控制台日志不提供足够的信息.
如何分析由tycho分叉的OSGi测试运行时中的bundle?
在远程调试模式下启动测试(只需-DdebugPort=8000在CLI上指定)并在本地端口上启动OSGi控制台,例如1234:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<systemProperties>
<osgi.console>1234</osgi.console>
</systemProperties>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果测试甚至没有启动,请在其中一个测试类中设置断点,或者在org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter中设置断点.然后,
telnet localhost 1234
Run Code Online (Sandbox Code Playgroud)
并且您可以使用通常的OSGi控制台命令ss, diag, bundle等来分析"体内"问题.
| 归档时间: |
|
| 查看次数: |
966 次 |
| 最近记录: |