[英]junit Test with SerenityParameterizedRunner in RunWith annotation: does not find tests (java.lang.Exception: No tests found matching Method)
我正在尝试使用IntelliJ IDEA在Serenity BDD框架上运行junit测试。
尝试运行测试时出现错误:
java.lang.Exception: No tests found matching Method ... from org.junit.internal.requests.ClassRequest@71e693fa
这似乎是由于使用RunWith注释调用了SerenityParameterizedRunner
@RunWith(SerenityParameterizedRunner.class)
注释掉RunWith批注后,将找到测试并开始执行测试(尽管并没有太大用处,因为我们依赖于参数化运行器来构建数据)。
我可以通过一个简单的项目重现该问题,以演示该问题。
package com.home;
public class Doorbell {
private int ringCount = 0;
public Doorbell() {
}
public void ring(){
System.out.println("Ring!");
ringCount++;
}
public int getRings() {
return ringCount;
}
}
测试类别:
package com.home;
import net.serenitybdd.junit.runners.SerenityParameterizedRunner;
import net.serenitybdd.junit.runners.SerenityRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SerenityParameterizedRunner.class)
public class DoorbellTest {
@Test
public void testRings()
{
Doorbell db = new Doorbell();
db.ring();
db.ring();
Assert.assertEquals(2,db.getRings());
}
}
的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"
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>homeproject</groupId>
<artifactId>mytestproject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<serenity.version>1.9.31</serenity.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.9.31</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-junit -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>1.9.31</version>
</dependency>
</dependencies>
</project>
Plesae尝试在项目中运行单个单元测试。 任何帮助,不胜感激。
这个Stack Overflow问题的答案11解决了我的问题
显然,您必须运行包含测试的类,而不是测试本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.