Intellij idea 获得;未发现任何测试错误“;在Junit5中执行测试类时
以下是我在Intellij Idea maven项目中使用的pom.xml文件:Intellij idea 获得;未发现任何测试错误“;在Junit5中执行测试类时,intellij-idea,junit5,Intellij Idea,Junit5,以下是我在Intellij Idea maven项目中使用的pom.xml文件: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<?xml version="1.0" encoding="UTF-8"?>
<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>groupId</groupId>
<artifactId>code</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
</plugins>
</build>
</project>
这是一个类,如果出于某种原因运行它,它不会运行测试函数删除
private
修饰符-它在测试方法中是不允许的。您可以在此处添加带有导入的测试类吗?添加了测试类是否需要添加@extendedwith(MockitoExtension.class)
测试类中的注释删除私有类是有效的。谢谢还有一件事。我使用Junit5的方式是否与JUnit test runner相同?我看到Junit4的Junit测试跑者。
package com.lab1;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PascalTriangleTests {
@Test
private void test(){
PascalTriangle pascalTriangle = new PascalTriangle();
pascalTriangle.generate(1);
assertEquals(pascalTriangle.getPascalTriangle().size(),1,"It should be one");
}
}