【问题标题】:Maven not finding Eclipse Plug-in testsMaven 找不到 Eclipse 插件测试
【发布时间】:2014-06-23 17:49:35
【问题描述】:

所以我有一个大型项目,我们现在正试图将测试集成到整个项目中(我知道)。但是当我运行一个

mvn clean install

在测试插件上,我收到消息

All Tests Passed!

但它显然没有运行测试,因为我的一个测试被写入失败。我的插件项目的结构是:

->src/${filepath}  */ My tests are here
->src/${filepath}/folderA
->src/${filepath}/folder
etc...

我有一个升级的主 pom 文件,用于编译所有依赖项(成功)。我的测试插件中的结构是否错误?

<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>

<version>1.0.0.qualifier</version>
<artifactId>com.exeeng.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<name>${name}</name>

<parent>
    <version>${parent-version}</version>
    <groupId>${parent-grou}</groupId>
    <artifactId>parent</artifactId>
</parent>
<properties>
    <tycho-version>0.19.0</tycho-version>
</properties>   
<build>
<plugins>
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho-version}</version>
        <extensions>true</extensions>
    </plugin>
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        </plugin>
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho-version}</version>
    </plugin>
    <plugin>
        <groupId>org.codehaus.tycho</groupId>
        <artifactId>maven-osgi-packaging-plugin</artifactId>
    </plugin>
</plugins>

【问题讨论】:

  • 在@Vwin 提到的要点之上,确保您的测试类名称为being with Test or end with Test,否则您将需要自定义配置。
  • 您在谈论 Eclipse 插件?你用的是第谷吗?如果您向我们展示您的测试 pom,将会很有用。
  • 这是我的测试 POM,测试都以 Test 结尾,所以应该可以正常工作。

标签: java eclipse maven junit


【解决方案1】:

根据 Maven 规范,maven 项目在 src/test/java 中有测试,在 src/test/resources 中有资源(默认)。你有这个结构吗?

我想补充一点,maven Junit 测试由 surefire-plugin 运行,它希望这是测试的默认目录结构。如果需要配置这个,check this

【讨论】:

  • 在我做的一个简单例子中,不一定是这样。
  • 我不明白你的意思。你能详细说明一下吗?
  • 抱歉,昨天比较忙。测试不一定要在 src/test/java 中才能找到,因为测试是在单独的插件中完成的。我有一个简单的例子,可以在 src/some_stuff/more_stuff/test/ 中进行测试SimpleJunitTest.java
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-24
  • 2012-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多