Can't be enable to #ignore annotation for the features - karate

Karate has #ignore annotation for the features.
https://github.com/intuit/karate#data-driven-features
I try to #ignore annotation, but it is not enable and the feature runs.
(use karate 0.9.2)
How can I use #ignore annotation for the features?
#ignore
Feature: API test
Background:
* url 'http://localhost:8089'
Scenario: Get all rentacycles
Given path '/rentacycles'
When method get
Then status 200
And assert response.size() === 5

There is no "special" annotation (actually there is just one which is #parallel=false)
So you can freely use any name for the annotation.
What is important is when you run your tests, you have to mention which annotation to use. See the documentation: https://github.com/intuit/karate#tags
Maybe this example will be clear: first.feature
To run tests with a tag:
mvn test -Dkarate.options="--tags #smoke"
And what you are asking is to NOT run:
mvn test -Dkarate.options="--tags ~#smoke"
Normally this is set on the JUnit runner like this example:
#KarateOptions(tags = "~#ignore")

Related

What is the gradle command to run scenarios with tags?

I am using Gradle 7.6, Karate 1.3.1, Java 17.0.5 and Junit 5.8.1.
I want to configure a Jenkin job for each feature to create a health check monitor. I need gradle commands to run feature files using tags #smoke, #regression, #featureName etc.,
I have tried with the following command, it worked earlier and stopped working recently.
./gradlew test -Dkarate.options="--tags #smoke" -Dtest.single=TestRunner#testTagsWithoutFeatureName
Where TestRunner is the following Java class
import com.intuit.karate.junit5.Karate;
public class TestRunner {
#Karate.Test
Karate testTagsWithoutFeatureName() {
return Karate.run().tags("#smoke").relativeTo(getClass());
}
}
My advice is use the Runner class, that is better designed for running tests in CI. The JUnit helpers are just for local-dev convenience: https://stackoverflow.com/a/65578167/143475
It should be possible to even pass a feature to karate.options as the last argument. Which might be more convenient than writing a Java class for every combinations. You should experiment.
Otherwise no suggestions, but if you feel there's a bug, follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue

gradle test: how to run one method?

How to run just one method of a test case for debugging with Gradle? I have tried:
gradle test -tests example.TestFoo#testMethod1 --debug-jvm
but it ends up with following error:
No tests found for given includes: example.TestFoo#testMethod1
The test TestFoo class has testMethod1(), testMethod2(), etc.
Use . instead # in your tests filter expression to point to a method name:
gradle test --tests example.TestFoo.testMethod1 --debug-jvm
You can find more examples on filtering tests in 48.14.3. Test filtering documentation section.

NoraUI - How to skip a scenario test?

I'm looking for a tag like "ignore" to skip a scenario test in NoraUI.
I tried this but it is not working :
#ignore
Scenario: 1 - Renvoi d’un rejet de mouvement Reflex
You not need add all run scenario tags in --tags of Maven command
sample:
-Dcucumber.options="--tags #hello,#bye,#Tag5,#tag10"
You can run all scenarios without some scenarios:
--tags ~#todo --tags ~#wip
full official notice here
Be careful, in NoraUi 3.x.x use io.cucumber => syntax change:
-Dcucumber.options="--tags '#hello or #bye or #Tag5 or #tag10'"

#Ignore tag on SpecFlow 2.0.0 results in build error

I've recently upgraded from SpecFlow 1.9.0 to 2.0.0 and NUnit 2.6.4 to 3.2.1.
The SpecFlow feature file snippet below used to work before, however it's failing with this error now: 'NUnit.Framework.IgnoreAttribute' does not contain a constructor that takes 0 arguments
#Register #Ignore
Feature: Registration page
This is the auto-generated SpecFlow feature class snippet that's failing:
[NUnit.Framework.IgnoreAttribute()]
How can #Ignore tags be used in SpecFlow 2.0.0 and NUnit 3.x?
The use of the tag has changed in the most recent version. Now you have to give it a reason ...
#Register #Ignore("reason")
Feature: Registration page
You have to regenerate the code-behind files of the feature files.
Then the IgnoreAttribute is generated with the correct parameters.

PHPUnit --loader: What is a test suite loader for?

PHPUnit manual say:
If you point the PHPUnit command-line test runner to a directory it will look for *Test.php files.
see: http://www.phpunit.de/manual/3.6/en/organizing-tests.html#organizing-tests.filesystem
This is wrong!
When i call:
phpunit --config myconfig.xml --bootstrap mybootstrap.php tests
It takes all php files.
First idea was to use blacklist or whitelist in the config xml, but then i realised, that these lists are filters for subject under tests and filters test classes.
Second thought was to use testsuites within the config xml. But at the moment the test suites can be defined only, but not executed via command line (not jet implemented in PHPUnit, ticket is open for more than 1 year).
Next thought was to use a test suite loader, but i can not find a documentation on how to use them and if a tsl is what i think it is.
When i run:
phpunit --config myconfig.xml --bootstrap mybootstrap.php --loader My_Testsuite_Loader tests
PHPUnit takes all php file in "tests/" and executes them. The file "My/Testsuite/Loader.php" will be included. PHPUnit checks if the class My_Testsuite_Loader exists. All fine so far.
I used the "PHPUnit/Runner/StandardTestSuiteLoader.php" as template for "My/Testsuite/Loader.php". It contains the methods "load()" and "reload()". Both methods are never called by the PHPUnit Framework. Why not? I thought to have a own testsuiteloder will give me the oportunity to implement a test suite exclude schema.
Sample file system of my project:
<root>
|-src/MyProject/Package/Object.php
|-tests/MyProject/Package/Object/TestTemplate.php
|-tests/MyProject/Package/Object/GetFooTest.php
|-tests/MyProject/Package/Object/GetBarTest.php
|-tests/phpunit.xml
|-tests/bootstrap.php
|-tests/My/Testsuite/Loader.php
As you can see i use one file for all tests about a sut (method under test). All these *Test.php files inherits from TestTemplate (TestCase). In TestTemplate.php is a setup which initializes the object (Object.php) and stores it in a private member var.
How to use the test suite loader / for what is it meant to be?
(How to exclude test classes that do not fit to the pattern: "*Test.php"?)
You need to take out the 'tests' argument like so
phpunit --config myconfig.xml --bootstrap mybootstrap.php
Then in your myconfig.xml
<testsuites>
<testsuite name="AllTests">
<directory>.</directory>
</testsuite>
<testsuites>
<filter>
<blacklist>
<directory suffix=".xml">.</directory>
<file>MyProject/Package/Object/TestTemplate.php</file>
</blacklist>
</filter>