How to run only xUnit tests with specific name through console/powershell? - powershell

I am currently running tests through Visual Studio interface, and that provides easy option to run only certain test. I want to do same, but through console / powershell.
Right now if I do dotnet test that will run all discovered tests. Is it possible to do something similar like dotnet test MyTest which would only run specific test?

Command dotnet test has switch --filter that allows you to filter tests and get only those that you want to run. So you can do:
dotnet test -t
To see full list of tests available, and then in order to just run specific ones you can do:
dotnet test --filter "FullyQualifiedName~ShouldInterconnect"
Which will execute only the tests containing ShouldInterconnect in the name.

Related

How do get pytest to do discovery based on module name, and not path

I'm looking at moving from unittest to pytest. One thing I like to do, is to do a setup.py install and then run the tests from the installed modules, rather than directly from the source code. This means that I pick up any files I've forgotten to include in MANIFEST.in.
With unittest, I can get the test runner to do test discovery by specifying the root test module. e.g. python -m unittest myproj.tests
Is there a way to do this with pytest?
I'm using the following hack, but I wish there was a built in cleaner way.
pytest $(python -c 'import myproj.tests; print(myproj.tests.__path__[0])')
The Tests as part of application section of pytest good practices says if your tests are available at myproj.tests, run:
py.test --pyargs myproj.tests
With pytest you can instead specify the path to the root test directory. It will run all the tests that pytest is able to discover. You can find more detail in the pytest good practices

How can I combine the PyDev unit test runner with Web2py?

I'm using Eclipse/PyDev on a Web2py application, and I'd like to create a launch configuration that runs a unit test using web2py.
Normally, Web2py wants you to run a unit test with a test runner script, like so:
python web2py.py -S testa -M -R testRunner.py
testRunner.py includes a main method that runs:
unittest.TextTestRunner(verbosity=2).run(suite)
However, in PyDev, the test running is managed outside of your source, in pysrc\runfiles.py.
PyDev's test runner doesn't even take -S, -M, and -R as arguments, and it has no way of passing them on to web2py.py, which it expects to be a suite of tests, and not a runner.
Is there a way to test Web2py using a PyDev unittest configuration, and if so, how?
My suggestion in this case is using the pytest runner (configure it in the pyunit preferences)... I haven't searched, but I bet there's some plugin for running web2py with pytest.

Can't run specific test specs based on namespace using sbt at the shell

I'm trying to run my specs2 tests from the shell as part of my CI build. When I run the following command on my local windows machine it runs the appropriate specs: specs defined in the Unit namespace.
sbt test:compile "test-only Unit.*"
However, on my build machine (ubuntu) it appears to ignore the namespace parameter to test-only and as a result runs all the tests. Single quotes don't seem to make a difference. When I enter the sbt console and then execute the command (test-only Unit.*) it works as expected.
Any suggestions would be appreciated.

Getting author tests to be created and run for dzil test

I am trying to use several Dist::Zilla plugins to generate and run author tests. The only problem is that they are generated by dzil build and not run with dzil test. As an example, here are some lines in my dist.ini:
[Test::Compile] ; Create t/00-compile.t
[Test::UnusedVars] ; Create xt/unused-vars.t
[RunExtraTests] ; run the xt/ tests when dzil test is run.
Running dzil test however, only runs one of the created test files- 00-compile.t. unused-vars.t isn't even created until I run dzil build. In order to test all of the author tests created like this, I need to first run dzil build, cd into the new directory, then run dzil test. Then, when something fails, I have to work with the original copy, not the copy created by the build command. Rinse and repeat.
Is there a way to get the author tests to be generated at build time so that I can run them with dzil test without changing directories?
dzil test --release is what you're looking for.
And I would also strongly recommend you to try Dist::Zilla::PluginBundle::TestingMania

How to further automate Teamcity

I have successfully configured my project for build in TeamCity. Going a step more, I want to run a deployment script once a build completes successfully. The deployment script is a simple bash command. To make the question more simpler, how would I invoke a shell command once a build successfully completes in Teamcity.
Please help
TeamCity 6.0 has a new feature called Multiple Build Steps:
Multiple Build Steps: Now any build configuration can be comprised of unlimited number of build steps, where each step is represented by a build runner. Don’t limit yourself, and combine as many build runners into one configuration as you need. Feel free to call a NAnt script before compiling VS solutions, run inspections and duplicates finder after your ANT build, add NUnit tests after your Rake build, and so on.
So you can add a new build step with the command line runner which will execute your shell script.