黄瓜junit runner java.lang.NoSuchMethodError:
发布时间:2020-08-04 20:17:44 所属栏目:Java 来源:互联网
导读:试图实施黄瓜做一些自动化测试. jUnit测试.我创建了2个文件并编辑了maven项目附带的pom.xml来添加依赖项.内容如下所示.两个文件中的第一个是黄瓜.feature文件,它是简单语言的小黄瓜.另一个是CukesRunner. java 当我使用Project运行我的测试时 – 以…运行 –
试图实施黄瓜做一些自动化测试. jUnit测试.我创建了2个文件并编辑了maven项目附带的pom.xml来添加依赖项.内容如下所示.两个文件中的第一个是黄瓜.feature文件,它是简单语言的小黄瓜.另一个是CukesRunner. java 当我使用Project运行我的测试时 – >以…运行 – > Maven测试它按预期工作. 但是,当我使用Eclipse Eclipse JUnit GUI运行CukesRunner.java文件时,出现错误: java.lang.NoSuchMethodError: org.junit.runner.Description.createSuiteDescription(Ljava/lang/String;Ljava/io/Serializable;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description; at cucumber.runtime.junit.FeatureRunner.getDescription(FeatureRunner.java:43) at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:77) at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:41) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:226) ... pom.xml中: <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.bdd</groupId> <artifactId>airportparking</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>airportparking</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.1.5</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.1.5</version> <scope>test</scope> </dependency> <dependency> <groupId>com.rubiconproject.oss</groupId> <artifactId>jchronic</artifactId> <version>0.2.6</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> </project> CukesRunner.java: package com.bdd.airportparking; import cucumber.api.junit.*; import org.junit.runner.RunWith; @RunWith(Cucumber.class) @Cucumber.Options( format={"pretty","html:target/cucumber"},features="src/test/resources" ) public class CukesRunner { } ValetParking.feature: Feature: Valet Parking As a traveler In order to determine where to park my car I want to know the cost of valet parking Scenario: Calculate valet parking cost for half an hour When I park my car in the Valet Parking Lot for 30 minutes Then I will have to pay $12 运行CukesRunner.java作为Junit测试时的输出: java.lang.NoSuchMethodError: org.junit.runner.Description.createSuiteDescription(Ljava/lang/String;Ljava/io/Serializable;[Ljava/lang/annotation/Annotation;)Lorg/junit/runner/Description; at cucumber.runtime.junit.FeatureRunner.getDescription(FeatureRunner.java:43) at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:77) at cucumber.api.junit.Cucumber.describeChild(Cucumber.java:41) at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:226) at org.junit.runner.Runner.testCount(Runner.java:38) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.countTestCases(JUnit4TestClassReference.java:30) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.countTests(RemoteTestRunner.java:487) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:455) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 我如何在eclipse中构建我的项目: 解决方法更新你的junit版本,也许你的surefire插件将解决这个问题.<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> 为了肯定: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> </plugin> </plugins> </build> (编辑:岳阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Java 8新特性 内建函数式接口详解
- 详解使用Redis SETNX 命令实现分布式锁
- java – 如何识别字符串是否包含不能使用utf8-mb4字符集存储
- 令人惊讶的行为Java 8 CompletableFuture异常的方法
- java – 将科学符号解释为int还是float?
- Java中的“synchronized(this)”vs.“synchronized((BaseCl
- 在Java8与Java7中HashMap源码实现的对比
- java – 什么是Eclipse最好的免费插件,允许格式/缩进/清理J
- Java使用JDBC向MySQL数据库批次插入10W条数据(测试效率)
- java – 如何将JSONObject转换为gson.JsonObject?