我的黄瓜功能文件位于我当地的下方位置:
C:\ProjectWork\Workspace\Cucumber\DIT_Cucumber\src\cucumber\featureOne.feature
Run Code Online (Sandbox Code Playgroud)
和Junit jar位于以下位置:
C:\DurgeshProjectWork\Workspace\JarFiles\junit-4.11.jar
Run Code Online (Sandbox Code Playgroud)
当我尝试了下面的几个命令从命令提示符执行功能文件时,但总是得到相同的错误
Could not fine class
Run Code Online (Sandbox Code Playgroud)
以下是我使用的命令:命令1:
C:\>java -cp C:\ProjectWork\Workspace\JarFiles\junit-4.11.jar org.junit.runner.JUnitCore C:\DurgeshProjectWork\Workspace\Cucumbe
r\DIT_Cucumber\bin\cucumber\featureOne.feature
Run Code Online (Sandbox Code Playgroud)
命令2:
C:\ProjectWork\Workspace\Cucumber\DIT_Cucumber\src\cucumber>java -cp C:\ProjectWork\Workspace\JarFiles\junit-4.11.jar org
.junit.runner.JUnitCore featureOne.feature
Run Code Online (Sandbox Code Playgroud)
你能帮我从命令行运行这个功能文件吗?提前致谢.
我正在学习 Cucumber 进行单元测试,并尝试为 Radix Sort 代码编写单元测试。但我无法弄清楚如何提供整数数组作为特征文件中基数排序代码的输入。
我尝试提供以下输入:
Scenario: Sorting integer array using radix sort within the specified range
Given The nonnull integer array 10,25,0,1
When radix sort is performed over the range from 0 to 7
Then validate if the array is sorted
Run Code Online (Sandbox Code Playgroud)
对于上述场景,cucumber 需要下面提到的代码体:
@Given("The nonnull integer array {double}")
public void the_nonnull_integer_array(Double double1) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试输入为
Scenario: Sorting integer array using radix sort within …Run Code Online (Sandbox Code Playgroud) 我有以下功能文件: MacroValidation.feature
@macroFilter
Feature: Separating out errors and warnings
Scenario: No errors or warnings when separating out error list
Given I have 0 macros
When I filter out errors and warnings for Macros
Then I need to have 0 errors
And I need to have 0 warnings
Run Code Online (Sandbox Code Playgroud)
我的定义文件.
package com.test.definition;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.runtime.java.StepDefAnnotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.doReturn;
import static org.powermock.api.mockito.PowerMockito.mock; …Run Code Online (Sandbox Code Playgroud) 我正在尝试用JUnit进行黄瓜测试,我得到了java.lang.NoClassDefFoundError例外.
JUnit代码:
package ctest;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature"
,glue={"stepDefinition"}
)
public class Runner {
}
Run Code Online (Sandbox Code Playgroud)
例外:
java.lang.NoClassDefFoundError: gherkin/formatter/Formatter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at cucumber.runtime.formatter.PluginFactory$1.<init>(PluginFactory.java:53)
at cucumber.runtime.formatter.PluginFactory.<clinit>(PluginFactory.java:52)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:69)
at cucumber.runtime.RuntimeOptionsFactory.create(RuntimeOptionsFactory.java:25)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:55)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at …Run Code Online (Sandbox Code Playgroud) 我正在使用 cucumber-jvm 在 Kotlin 中执行一些功能测试。
我有标准的空跑步者课程:
@RunWith(Cucumber::class)
@CucumberOptions(features=[foo],
glue=[bar],
plugin=[baz],
strict=true,
monochrome=true)
class Whatever
Run Code Online (Sandbox Code Playgroud)
实际步骤是在另一个类中使用 @ContextConfiguration springframework 注解定义的。该类还使用其他 spring 功能,如 @Autowire 或 @Qualifier
@ContextConfiguration(locations=["x/y/z/config.xml"])
class MyClass {
...
@Before
...
@Given("some feature file stuff")
...
// etc
}
Run Code Online (Sandbox Code Playgroud)
这一切在 Cucumber 版本 4.2.0 中都可以正常工作,但是升级到版本 6.3.0 就会出现问题。更新导入以匹配新的 Cucumber 项目布局后,测试现在失败并出现以下错误:
io.cucumber.core.backend.CucumberBackendException:请使用一些上下文配置注释胶水类。
它提供了示例来说明其含义...
例如:
@CucumberContextConfiguration
@SpringBootTest(classes = TestConfig.class)
public class CucumberSpringConfiguration {}
Run Code Online (Sandbox Code Playgroud)
或者:
@CucumberContextConfiguration
@ContextConfiguration( ... )
public class CucumberSpringConfiguration {}
Run Code Online (Sandbox Code Playgroud)
看起来它告诉我我可以将 @CucumberContextConfiguration 添加到 MyClass 中。
但为什么?
我明白了 @CucumberContextConfiguration 的意思,这里解释得很好,但是为什么我现在需要版本 6,而版本 4 …
在我的黄瓜-jvm,Maven,junit Setup中我将testRunner文件作为
package com.lebara.testrunner;
import cucumber.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@Cucumber.Options(
glue = {"com.lebara.stepdefs","com.lebara.framework.main", "com.lebara.testrunner"},
features = "C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources",
format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-report.json"},
tags = {"@UserJourney"}
)
public class RunCukesTest {
}
Run Code Online (Sandbox Code Playgroud)
我在上面提到的目录中有我的功能文件.
如果我运行它,我会得到以下异常:
cucumber.runtime.CucumberException: No features found at [C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources/cucumber]...
Run Code Online (Sandbox Code Playgroud)
如果我删除了testrunner中的"features"选项,它会尝试在与我的testrunner.java相同的目录中查找功能文件
cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]
Run Code Online (Sandbox Code Playgroud)
如果我把功能文件放在那里,它就可以了.
我的问题是为什么我的功能文件没有被我以前的位置拾取,我认为这是黄瓜 - maven设置的默认文件结构.
我如何从那里取货?帮助赞赏.
考虑我有以下功能文件:
登录功能
功能:登录网站
场景:现场登录验证
首页.专题
功能:欢迎页面验证
场景:验证登录后出现的页面
在Home.feature文件中,我需要先执行Login.feature,然后调用home.feature。因此,当我从跑步者测试中执行 home 时,它将依次执行登录,然后执行 home。
RunnerTest.java
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(strict = false, features = {
"src/test/resources/Features/Home.feature",
}, glue = { "tests" }, plugin = "html:target/cucumber-reports", format = { "pretty",
"json:target/cucumber.json" }, tags = { "~@ignore" })
public class RunnerTest {}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在IntelliJ中运行黄瓜功能文件。
Cucumber Options指向正确的文件夹,但是在尝试执行JUnit运行器类时收到“无可用任务”通知。
我究竟做错了什么?
这是我的build.gradle:
plugins {
id 'java'
}
sourceCompatibility = 1.8
apply plugin: 'java'
repositories {
mavenCentral()
}
compileJava.options.encoding = "UTF-8"
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:4.7.1'
compile 'org.seleniumhq.selenium:selenium-server:2.44.0'
testImplementation 'io.cucumber:cucumber-java:4.7.1'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
compile group: 'io.cucumber', name: 'cucumber-java', version: '4.7.1'
compile group: 'io.cucumber', name: 'cucumber-junit', version: '4.7.1'
compile group: 'io.cucumber', name: 'cucumber-core', version: '4.7.1'
compile group: 'net.masterthought', …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的黄瓜测试迁移到 ,cucumber-junit以便cucumber-junit-platform-engine能够使用新的平台功能。如何重新定义我的跑步者以使用旧的@CucumberOptions. 我正在调查这个问题,但似乎还找不到正确的方法。
在我使用这些选项之前:
@CucumberOptions(
plugin = ...,
features = ...,
tags = ...,
glue = ...
)
Run Code Online (Sandbox Code Playgroud)
有没有直接的方法将其迁移到平台引擎?
我在 Jenkins 上运行构建时遇到异常,构建失败的场景是项目的集成测试部分。然而,我的所有 junit 和 cucumber 测试用例在我的本地机器上都运行良好。
我在 Jenkins 服务器上收到的异常。
field - $jacocoData Exception is - java.beans.IntrospectionException: Method not found: is$jacocoData
Run Code Online (Sandbox Code Playgroud) cucumber-junit ×10
cucumber ×7
cucumber-jvm ×4
java ×4
junit ×3
bdd ×1
jenkins ×1
junit5 ×1
selenium ×1
unit-testing ×1