2013-11-26 251 views
1

这是万无一失的Maven插件我使用Maven的Eclipse中运行测试套件

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.16</version> 
    <configuration> 
    <includes> 
    <include>runner.TestSuite.java</include> 
    </includes> 
    <skipTests>true</skipTests> 
    </configuration> 
</plugin> 

这是TestSuite类

package runner; 

import org.junit.runner.RunWith; 
import org.junit.runners.Suite; 

import action.TestLogin; 
import action.TestRegister; 

@RunWith(Suite.class) 
@Suite.SuiteClasses({ TestRegister.class, TestLogin.class }) 
public class TestSuite { 
} 

测试套件运行正常的一个人。 但是,当我运行maven-eclipse安装时,我想运行测试套件而不单独运行所有测试用例。但它说

[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ FinalProject --- 
[INFO] Tests are skipped. 

此外,我使用声纳来检查线覆盖也是无法检测到testSuite我作出。 我是新来的Junit TestSuite &不知道如何用maven &声纳配置它们。

任何链接,参考或线索将有所帮助。 谢谢。

+2

删除线'真正'否则测试将无法运行。 – khmarbaise

+0

感谢您的回复,虽然它没有帮助,因为我希望maven运行TestSuite类并通过它运行测试用例。 但是,如果你所说的删除行,所有的测试用例都将由maven运行,这是不可取的。 请告诉你是否清楚的问题。谢谢 –

回答

2

确保你有你的pom.xml

<dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.11</version> 
     <scope>test</scope> 
</dependency> 

这是需要上手的唯一步骤指定的JUnit依赖 - 您现在可以创建在您的测试源目录测试。

更多关于这在Maven Surefire Plugin

+0

感谢您的答复。我有提到的依赖。 我想要的是当我运行maven-install测试套件应该运行。 但是这不会发生,因为 true这一行;我需要这条线,以便maven不会按照它获得的顺序运行测试用例。 –