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

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.

Related

before, beforeEach, after, and afterEach of mocha equivalent in pytest

I'm new to python and using pytest along with requests to start API testing.
I want to run some scripts before each test module and other snippets before each test case in a module for testcases data setup.
I've checked pytest fixtures and scope but I don't think this is what I'm looking for as I can't control the data passed to fixtures. What other possible solutions for that?

How to run only xUnit tests with specific name through console/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.

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

Run Selenium tests in parallel for Play Project

I have a Play Project (using Scala) with a bunch of Selenium tests in a file.
I am using SBT as my build tool. In my SBT console, I run the tests file using:
sbt "test-only test.selenium.MySpec". I see that all the tests are running sequentially even though I have sbt.Keys.fork in Test set to true (it's the default, I believe).
I am using Firefox browser for my Selenium tests. I am on Selenium 2.42.0, Play 2.2.2, SBT 0.13.0 and Scala 2.10.4 if that matters.
Is it possible to run the tests in parallel (on my local machine) ? I have seen other options like Selenium Grid where I can distribute my tests by horizontal scaling, but I am trying to have this setup on my local machine.
Fork does not mean "run in parallel". Fork means "start a new JVM process to run the tests".
Sbt 0.13.5 has some new/experimental code to run forked tests in parallel. You can enable this via the following setting:
testForkedParallel in Test := true
try it out and let us know if you run into any issues. I expect we'll be investing more time into handling parallel log collection in the future, but for now what's there should be good enough for basic tests and development.

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.