gpt4 book ai didi

selenium-webdriver - 我如何在 cucumber 中运行特定场景

转载 作者:行者123 更新时间:2023-12-05 00:51:58 25 4
gpt4 key购买 nike

如何在多个场景中在 cucumber 中运行特定场景?
功能文件

Feature: Test Test Smoke scenario

Scenario: Test login with valid credentials
Given open firefox and start application
哈哈哈哈哈
当我点击登录
并输入有效的“kumar.rakesh@yopmail.com”和有效的“admin@123”
然后点击登录,用户应该能够成功登录
  Scenario: Test shop for cart
Given Click on shop for carts
And select plates
When Click on Add to cart
Then product should be added in the cart successfully
And verify the product

Scenario: Test login with valid credentials1
Given open firefox and start application
When I click on Login
And enter valid "kumar.rakesh@yopmail.com" and valid "admin@123"
Then Click on login and User should be able to login successfully

Scenario: Test shop for cart1
Given Click on shop for carts
And select plates
When Click on Add to cart
Then product should be added in the cart successfully
And verify the product
测试运行器
package runner;

import org.junit.runner.RunWith;

import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@Cucumber.Options(features="features",glue={"steps"},format = {"pretty", "html:target/Destination"})

public class TestRunnr {

}

最佳答案

在 cucumber 中使用标签 future ,如下所示。

Feature: Test Milacron Smoke scenario

@Test1
Scenario: Test login with valid credentials
Given open firefox and start application
When I click on Login
And enter valid "kumar.rakesh@thoughtfocus.com" and valid "Thought@123"
Then Click on login and User should be able to login successfully

@Test2
Scenario: Test shop for cart
Given Click on shop for carts
And select plates
When Click on Add to cart
Then product should be added in the cart successfully
And verify the product

@Test3
Scenario: Test login with valid credentials1
Given open firefox and start application
When I click on Login
And enter valid "kumar.rakesh@thoughtfocus.com" and valid "Thought@123"
Then Click on login and User should be able to login successfully

@Test4
Scenario: Test shop for cart1
Given Click on shop for carts
And select plates
When Click on Add to cart
Then product should be added in the cart successfully
And verify the product

如果您只想运行 Test1 场景更新运行程序文件,如下所示。
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features="features",glue={"steps"},format = {"pretty", "html:target/Destination"},tags={"@Test1"})
public class TestRunner {

}

如果要执行多个场景,请保留逗号分隔的标签,如下所述。
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features="features",glue={"steps"},format = {"pretty", "html:target/Destination"},tags={"@Test1,@Test2"})
public class TestRunner {

}

关于selenium-webdriver - 我如何在 cucumber 中运行特定场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43541076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com