标签: surefire

让Maven运行所有测试,即使有些失败

我有一个包含几个模块的项目.当所有测试通过后,Maven测试将全部运行.

当第一个模块中的测试失败时,maven将不会继续下一个项目.我在Surefire设置中将testFailureIgnore设置为true,但它没有帮助.

如何让maven运行所有测试?

java maven-2 surefire

234
推荐指数
5
解决办法
13万
查看次数

如何运行Maven Integration测试

我有一个maven2多模块项目,在我的每个子模块中,我都有JUnit测试,这些测试都是命名的Test.java,分别Integration.java用于单元测试和集成测试.当我执行:

mvn test

*Test.java执行子模块中的所有JUnit测试.当我执行

mvn test -Dtest=**/*Integration

没有任何Integration.java测试在子模块中执行.

这些看起来像是完全相同的命令,但是带有-Dtest =/*Integration**的命令不起作用它显示在父级别运行的0个测试,没有任何测试

java testing maven-2 surefire

160
推荐指数
8
解决办法
19万
查看次数

JUnit测试在Eclipse中传递但在Maven Surefire中失败

我已经使用JUnit 4和spring-test库编写了一些JUnit测试.当我在Eclipse中运行测试然后运行正常并通过.但是当我使用Maven运行它们时(在构建过程中),它们无法给出与弹簧相关的错误.我不确定导致问题的是什么,JUnit,Surefire或Spring.这是我的测试代码,弹簧配置和我从Maven获得的异常:

PersonServiceTest.java

package com.xyz.person.test;

import static com.xyz.person.util.FjUtil.toFjList;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.xyz.person.bo.Person;
import com.xyz.person.bs.PersonService;

import fj.Effect;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:personservice-test.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class PersonServiceTest {

    @Autowired
    private PersonService service;

    @Test
    @Transactional
    public void testCreatePerson() {
        Person person = new Person();
        person.setName("abhinav");
        service.createPerson(person);

        assertNotNull(person.getId());
    }

    @Test
    @Transactional
    public void testFindPersons() {
        Person …
Run Code Online (Sandbox Code Playgroud)

java spring maven-2 spring-test surefire

86
推荐指数
7
解决办法
9万
查看次数

在控制台中制作maven的surefire show stacktrace

我想在控制台中看到单元测试的堆栈跟踪.surefire是否支持这个?

maven-2 unit-testing stack-trace surefire

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

如何获取测试资源文件?

在单元测试中,我需要导入一个csv文件.它位于资源文件夹中,即src/test/resources

java testing resources surefire maven

58
推荐指数
4
解决办法
7万
查看次数

有没有办法在maven中只跳过一次测试?

我想在发布时只跳过一次测试mvn install.

有没有办法做到这一点 ?

maven-2 surefire

56
推荐指数
6
解决办法
4万
查看次数

TypeNotPresentExceptionProxy

从Surefire 2.6升级到Surefire 2.13时,我TypeNotPresentExceptionProxy在运行单元测试时得到了一个.

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
    at java.lang.Class.getAnnotation(Class.java:3029)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:64)
Run Code Online (Sandbox Code Playgroud)

JUnit4TestChecker,第64行看起来像这样:

Annotation runWithAnnotation = testClass.getAnnotation( runWith );
Run Code Online (Sandbox Code Playgroud)

所以Surefire检查@RunWith注释以确保其类型有效.我们的测试使用Spring,所以@RunWith在我们的测试类中看起来像这样:

@RunWith(SpringJUnit4ClassRunner.class)
Run Code Online (Sandbox Code Playgroud)

似乎Surefire没有找到这个SpringJUnit4ClassRunner班级.我不确定为什么因为在Surefire 2.6下,测试运行良好.

有任何想法吗?

java junit exception surefire maven

51
推荐指数
1
解决办法
7579
查看次数

Maven 2.1.0没有将系统属性传递给Java虚拟机

在Linux 机器上运行Hudson构建时,我们使用命令行将系统属性传递给Java虚拟机.它曾经在2.0.9中很好地工作,因为我们升级到2.1.0它已经完全停止工作.系统属性永远不会进入Java虚拟机.

我创建了一个小型测试项目,实际上根本不起作用.

这应该适用于Maven 2.0.9:

mvn2.0.9 -Dsystem.test.property=test test 
Run Code Online (Sandbox Code Playgroud)

但这会失败:

mvn2.1 -Dsystem.test.property=test test 
Run Code Online (Sandbox Code Playgroud)

Java代码就是这么做的

assertTrue( System.getProperty("system.test.property") != null); 
Run Code Online (Sandbox Code Playgroud)

maven-2 jvm system-properties maven-plugin surefire

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

使用maven surefire插件有没有办法让junit"快速失败"?

我目前正在使用maven开发一个java项目.我们使用maven surefire插件来运行我们的junit套件作为构建过程的一部分.

我们的测试套件在覆盖范围和执行时间都在快速增长.当您在测试的第一分钟内等待十分钟以发现测试失败时,执行时间非常令人沮丧且耗时.

我想找到一种方法,使构建过程在测试套件中的第一个错误/失败时失败.我知道这对于其他构建工具是可行的,但是我一直无法找到使用maven surefire来做到这一点的方法.

我知道在surefire jira 中有一个未解决的此功能的票证,但我希望有一个现有的解决方案.

junit maven-2 surefire

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

是否有适合Maven的HTML Junit报告插件?

我发现surefire-report插件非常不适合我的工作方式.我一直在清理项目,每次想在浏览器中查看测试报告时,我都不想花5分钟重建整个站点.

如果我输入mvn surefire-report:report-only,生成的报告太难看了,几乎无法读取.

我正在寻找的是像蚂蚁的JUnitReport任务.那里有可用的吗?

java ant maven-2 surefire

36
推荐指数
3
解决办法
4万
查看次数