配置为不使用时,标签仍为 运行 的功能
Feature with tag still being run when configured not to
我有一个主要特征文件,其中包含一个 "setup" 特征文件,该文件应该添加一些测试数据。这个设置特征文件有一个注释,我称之为 @ignore
。但是,按照此 SO 答案中的说明进行操作,但我仍然看到设置功能文件 运行 在主要测试功能之外。
主要功能文件,unsubscribe_user.feature
:
Feature: Unsubscribe User
Background:
* def props = read('properties/user-properties.json')
* url urlBase
* configure headers = props.headers
* def authoriZation = call read('classpath:basic-auth.js') { username: 'admin', password: 'admin' }
* def testDataSetup = call read('classpath:com/meanwhileinhell/app/karate/feature/mockserver/testDataSetup.feature') { data1: #(props.data1), data2: #(props.data2) }
Scenario: Unsubscribe user
...
...
Scenario: Remove test data
* def testDataTearDown = call read('classpath:com/meanwhileinhell/app/karate/feature/mockserver/testDataTearDown.feature') { data1: #(props.data1), data2: #(props.data2) }
...
testDataSetup.feature
文件
@ignore
Feature: Add data to REST Mock Server
Background:
* url mockServerUrlBase
Scenario: Add data
* print 'Adding test data'
Given path 'mapping'
And request { data1: '#(data1)', data2: '#(data2)' }
When method post
Then status 201
现在从我的 Java 运行ner class, 我添加了 @KarateOptions(tags = "~@ignore")
.
import org.junit.runner.RunWith;
import com.intuit.karate.KarateOptions;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
@RunWith(Karate.class)
@CucumberOptions(features = "classpath:com/meanwhileinhell/app/karate/feature/unsubscribe_user.feature")
@KarateOptions(tags = "~@ignore")
public class KarateTestUnSubscribeUserRunner {
}
但是,我仍然可以看到我的设置 class 中的打印语句被调用,并且执行了两个 POST。我也尝试 运行 使用以下 cmd 选项连接我的套件,但同样,仍然看到功能文件 运行 两次。
./gradlew clean test -Dkarate.env=local -Dkarate.options="--tags ~@ignore" --debug
我是不是跟错了?有什么东西可以添加到我的 karate-config.js
文件中吗?我正在使用空手道版本 0.9.0.
注释仅适用于 "top level" 功能。不在 "called" 个功能上。
如果您的问题是这些功能 运行 即使不是预期的,您一定是遗漏了一些东西,或者某些 Java class 运行ning 没有知道它。所以请遵循这个过程,我们可以修复它:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
编辑:我想我明白了 - 请不要混用 CucumberOptions
,事实上我们已弃用它,仅使用 KarateOptions
。即使在 0.9.5 之后也不推荐这样做,您应该转移到 JUnit 5。
我有一个主要特征文件,其中包含一个 "setup" 特征文件,该文件应该添加一些测试数据。这个设置特征文件有一个注释,我称之为 @ignore
。但是,按照此
主要功能文件,unsubscribe_user.feature
:
Feature: Unsubscribe User
Background:
* def props = read('properties/user-properties.json')
* url urlBase
* configure headers = props.headers
* def authoriZation = call read('classpath:basic-auth.js') { username: 'admin', password: 'admin' }
* def testDataSetup = call read('classpath:com/meanwhileinhell/app/karate/feature/mockserver/testDataSetup.feature') { data1: #(props.data1), data2: #(props.data2) }
Scenario: Unsubscribe user
...
...
Scenario: Remove test data
* def testDataTearDown = call read('classpath:com/meanwhileinhell/app/karate/feature/mockserver/testDataTearDown.feature') { data1: #(props.data1), data2: #(props.data2) }
...
testDataSetup.feature
文件
@ignore
Feature: Add data to REST Mock Server
Background:
* url mockServerUrlBase
Scenario: Add data
* print 'Adding test data'
Given path 'mapping'
And request { data1: '#(data1)', data2: '#(data2)' }
When method post
Then status 201
现在从我的 Java 运行ner class, 我添加了 @KarateOptions(tags = "~@ignore")
.
import org.junit.runner.RunWith;
import com.intuit.karate.KarateOptions;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
@RunWith(Karate.class)
@CucumberOptions(features = "classpath:com/meanwhileinhell/app/karate/feature/unsubscribe_user.feature")
@KarateOptions(tags = "~@ignore")
public class KarateTestUnSubscribeUserRunner {
}
但是,我仍然可以看到我的设置 class 中的打印语句被调用,并且执行了两个 POST。我也尝试 运行 使用以下 cmd 选项连接我的套件,但同样,仍然看到功能文件 运行 两次。
./gradlew clean test -Dkarate.env=local -Dkarate.options="--tags ~@ignore" --debug
我是不是跟错了?有什么东西可以添加到我的 karate-config.js
文件中吗?我正在使用空手道版本 0.9.0.
注释仅适用于 "top level" 功能。不在 "called" 个功能上。
如果您的问题是这些功能 运行 即使不是预期的,您一定是遗漏了一些东西,或者某些 Java class 运行ning 没有知道它。所以请遵循这个过程,我们可以修复它:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
编辑:我想我明白了 - 请不要混用 CucumberOptions
,事实上我们已弃用它,仅使用 KarateOptions
。即使在 0.9.5 之后也不推荐这样做,您应该转移到 JUnit 5。