JUNIT测试通过,但是hansel测试覆盖率的时候报错了,报错信息如下 求支援
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JUNIT测试通过,但是hansel测试覆盖率的时候报错了,报错信息如下 求支援相关的知识,希望对你有一定的参考价值。
junit.framework.AssertionFailedError: No tests found in tteesstt.MyAHansel
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:263)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
spring && Cobertura && maven &&junit 单元测试以及测试覆盖率
1. 目的:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dalong.demoapp</groupId>
<artifactId>junitdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.5.release</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.5.release</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>xml</format>
</formats>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package junitdemo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
publicclassUserOperator{
@Bean
publicUserService userService(){
UserService info =newUserService();
return info;
}
}
package junitdemo;
import java.util.Date;
publicclassUserService{
publicUserInfo userInfo(){
UserInfo info =newUserInfo();
info.setDate(newDate());
info.setAge(333);
info.setInfo("dddddd");
return info;
}
}
package junitdemo;
import java.util.Date;
publicclassUserInfo{
privateDate date;
publicDate getDate(){
return date;
}
publicvoid setDate(Date date){
this.date = date;
}
publicString getInfo(){
return info;
}
publicvoid setInfo(String info){
this.info = info;
}
publicint getAge(){
return age;
}
publicvoid setAge(int age){
this.age = age;
}
privateString info;
privateint age;
}
package junitdemo;
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.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes =UserOperator.class)
publicclassUserOperatorTest{
@Autowired
publicUserService userService;
@Test()
publicvoid testUserOperator(){
for(int i =0; i <100; i++){
UserInfo info = userService.userInfo();
System.out.println(info.toString());
}
}
}
mvn cobertura:cobertura
以上是关于JUNIT测试通过,但是hansel测试覆盖率的时候报错了,报错信息如下 求支援的主要内容,如果未能解决你的问题,请参考以下文章
如何通过非 maven 项目的声纳的 junit 测试来测量代码覆盖率