测试数据:-
1) Java版本“1.8.0_121”Java(TM)SE运行时环境(构建1.8.0_121-b13)Java热点(TM)64位服务器虚拟机(构建25.121-b13,混合模式)
2) eclipseideforjava开发人员版本:Neon。2版本(4.6.2)构建id:20161208-0600
3) OS Microsoft Windows 10 Home-64位
我的特征。特色
Feature: This is my dummy feature file
Scenario: This is my first dummy scenario
Given This is my first dummy given step
When This is my second dummy given step
Then This is my third dummy given step
步骤。JAVA
package com.cucumber.mavenCucumberPrototype;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class steps
{
@Given("^This is my first dummy given step$")
public void This_is_my_first_dummy_given_step() throws Throwable
{
System.out.println("Executed the first given step");
}
@When("^This is my second dummy given step$")
public void This_is_my_second_dummy_given_step() throws Throwable
{
System.out.println("Executed the first when step");
}
@Then("^This is my third dummy given step$")
public void This_is_my_third_dummy_given_step() throws Throwable
{
System.out.println("Executed the first then step");
}
}
RunnerTest。JAVA
package com.cucumber.mavenCucumberPrototype;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:features"
)
public class RunnerTest
{
}
波姆。XML
http://maven.apache.org/xsd/maven-4.0.0.xsd"
<groupId>com.cucumber</groupId>
<artifactId>mavenCucumberPrototype</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mavenCucumberPrototype</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
堆栈跟踪:-
java.lang.TypeNotPresentException: Type cucumber.junit.Cucumber not present
at sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:46)
at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:84)
at com.sun.proxy.$Proxy2.value(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: cucumber.junit.Cucumber
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:439)
at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:420)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:349)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at org.junit.internal.builders.IgnoredBuilder.runnerForClass(IgnoredBuilder.java:10)
... 11 more
通信线路输出:-
C:\Users\Pragati Chaturvedi\workspace\mavenCucumberPrototype>mvn clean
install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mavenCucumberPrototype 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @
mavenCucumberPrototype ---
[INFO] Deleting C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
mavenCucumberPrototype ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
mavenCucumberPrototype ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ mavenCucumberPrototype ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
mavenCucumberPrototype ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @
mavenCucumberPrototype ---
[INFO] Surefire report directory: C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.cucumber.mavenCucumberPrototype.RunnerTest
No features found at [classpath:features]
0 Scenarios
0 Steps
0m0.000s
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.331 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ mavenCucumberPrototype
---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\target\mavenCucumberPrototype-
0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @
mavenCucumberPrototype ---
[INFO] Installing C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\target\mavenCucumberPrototype-
0.0.1-SNAPSHOT.jar to C:\Users\Pragati
Chaturvedi\.m2\repository\com\cucumber\mavenCucumberPrototype\0.0.1-
SNAPSHOT\mavenCucumberPrototype-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\Pragati
Chaturvedi\workspace\mavenCucumberPrototype\pom.xml to C:\Users\Pragati
Chaturvedi\.m2\repository\com\cucumber\mavenCucumberPrototype\0.0.1-
SNAPSHOT\mavenCucumberPrototype-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.794 s
[INFO] Finished at: 2017-04-12T01:36:58-04:00
[INFO] Final Memory: 17M/194M
[INFO] ------------------------------------------------------------------------
http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException`C:\Use rs\PragatiChaturvedi\workspace\mavencumberprototype\src\test\java\com\cu cumber\mavencumberprototype
这是一个maven项目,javac不是编译/构建项目的方式。
如果我错了,请纠正我,但我假设你不知道maven。这是一些关于maven的教程。
尝试从C:\Users\PragatiChaturvedi\workspace\MavenCumberPrototype运行mvn clean install
,查看是否正在执行测试。
我在我的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>groupId</groupId>
<artifactId>CucumberBasic</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
我试图运行cucumber测试,但我得到以下异常。我用那些罐子和它们的版本 这是我的项目: 这是testRunner类代码: 场景:当用户导航到登录页面并输入用户名和密码时,使用给定的有效凭据成功登录,并在主页上输入用户名和密码,然后显示消息,登录成功 场景:成功注销当用户从应用程序注销时,消息显示注销成功
我正在为StandardAlone java类编写一个Junit测试用例。我在初始化Class对象时获取nullPointerException。这是我的代码。非常感谢任何帮助 这是我的课
问题内容: 我正在使用mocha-phantomjs设置进行单元测试。我有以下package.json脚本来运行测试。 在浏览器中可以正常运行。当我在cmd中运行命令时,测试运行正常,但同时也会出现以下错误 请任何人告诉我如何解决此错误。 问题答案: 当我在cmd中运行命令npm test时,测试运行正常 不,他们不是。您有6个失败的测试。的退出代码等于测试失败的次数。直接运行,看看有什么问题。意
运行单个测试时引发错误: 通过点击方法名称旁边的绿色三角形按钮启动测试。 但是如果你通过maven(生命周期)对整个项目进行测试- 要使用JUnit,需要使用以下依赖项: 负责这个项目的其他团队成员(一个存储库,不同的分支)没有这样的问题。是什么导致了这个错误?使用了IDE-IntelliJ IDEA UPD:我什么都试过了。删除。idea文件夹没有效果,也没有重新下载所有依赖项。清除缓存也没有效
我刚刚添加了测试单元,当我使用运行它时,我得到了错误,测试将失败。但是,当我运行时,一切看起来都很好,我不知道发生了什么黑客。我认为当我使用运行时,无法识别部分文件,并将抛出新的错误。 这是我的代码https://github.com/rohmanhm/unobuilder/tree/test 下面是错误消息。 rohmanhm~/desktop/code/works/unobuilder tes
使用: cucumber芯-1.2.4 cucumber-java-1.2.4 cucumber-junit-1.2.4 Junit-4.12 Eclipse Mars.1 Java 8