run tests only from a specific collection using xunit.console - xunit

How do I run unit tests using the xunit console runner that belong to a specific collection?
I can run at the class or method level using the -class or -method switch.

Related

WebdriverIO + Jasmine: How to exclude a specific test file when running a suite based on that test file name

We are on latest 8.X WebdriverIO version and latest Jasmine 4.X at this moment, using latest Node 18.X.
In my Wdio.conf.js file I have suite:
all: [ 'path/test1.js', 'path/test2.js'],
test1.js has a Describe with value "SMOKE test 1", while test2.js has "test 2".
I want to run --suite=all but exclude all files that DOESN'T contain "SMOKE" in the title, or run --suite=all but include only tests which contains "SMOKE" in the title.
Is this possible, and how? I'm having real troubles finding examples for this case. Can we use grep for this example somehow? I don't have an idea how can we do it.
Basically, the idea is to run only smoke test from some suite. We are not using Mocha and Cucumber runners which have additional tagging, so we are basically running suites all the time. I don't want to create more suites and divide tests in separate suites, we have to many test files.
I tried following the documentation, but I'm having troubles using their example:
grep -r -l --include "*.js" "myText" | wdio wdio.conf.js

How to exclude a project from dotnet test run

I have two projects: UnitTests.csproj (xunit) and IntegrationTests.csproj (specflow)
I'm using
dotnet test MySolution.sln --filter FullyQualifiedName\!~IntegrationTests
to run unit tests.
However, my IntegrationTests.csproj project contains a method decorated with [AfterTestRun] attribute, and it appears that my command runs that method, understandably, even though no tests were run from IntegrationTests.csproj project.
I have tried putting [Category("Integration")] on the [AfterTestRun]-decorated method, but that doesn't seem to be helping.
Question: How can I filter test lifecycle methods with dotnet test and xunit?
My workaround is to add the following code to all integration test lifecycle methods:
if (Environment.GetEnvironmentVariable("TEST_SERVER_URL") is null) return;

What is relation of Cucumber feature files with Test Runner file in Karate?

I have found if I only add karate core dependency and run my tests, they run fine and report is generated.
So what is importance of making a test runner class? I can run my karate tests without it as well. Kindly explain!
With Karate runner class , you can use #KarateOptions to include or exclude feature files that you want to run eg #KarateOptions(features = "classpath:FeatureFiles/test.feature" , tags = "~#Smoke") will run all feature files other than the one having #Smoke tag .
How to pass parameter to run Karate tests from cmd/terminal as maven project
If we want to run only 'Smoke' tests then code can be written as :
Open cmd/terminal
cd 'karate project path'
mvn test -Dkarate.options="--tags #Smoke classpath:FeatureFiles"

How to add build step in team city to run Node Js unit tests (Mocha framework)

I have a NodeJs application. Currently I am using team city for build and deployment of this application.
Now I want to run unit test cases before deployment. I have used Mocha framework with Chai to write test cases.
I don't see any runner type for Mocha or Node Js in team city.
I know some plugin is needed to be installed on teamcity server.
does any one know what is the plugin and what steps I need to follow?
You don't have to install any specific TeamCity plugin, you have to use test reporter capable of writing TeamCity service messages, e.g. mocha-teamcity-reporter, which is just another npm package.
You'll get you tests consumed by TeamCity after you run mocha --reporter mocha-teamcity-reporter test in your build step, so Command-Line Runner may be used for this purpose.
It is a good practice to extract this command to a separate script in your package.json, e.g:
"test:ci": "mocha --reporter mocha-teamcity-reporter test"
and use npm run test:ci in your build step.

Selenium : How to execute test cases at parallely using cucumber with maven

We have execute the different test scenarios in different feature file using cucumber with maven in eclipse.
EX:
FeatureFile1:Login1
Scenario:UserLogin
Given:the userName is "aaa"
When:the login button is clicked
Then:the user login as successfully
FeatureFile2:Login2
Scenario:UserLogin01
Given:the userName is "bbb"
When:the login button is clicked
Then:the user login as successfully
In above example how to run in parallels and also how to configure in pom.xml file.
Regards,
Gopal
I have no idea how to solve it using maven only. I'm using jbehave and run tests in parallel with testng. It provides xml which operates test running and there you could specify amount of parallel threads and what exactly should be paralleled (metods, tests, suits). On build server use maven command:
mvn test -Dtestng.xml.file=suite.xml
Also you could use surefire plugin with any test provider.
http://testng.org/doc/index.html
http://maven.apache.org/surefire/maven-surefire-plugin/index.html

Resources