Run Selenium tests in parallel for Play Project - scala

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.

Related

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.

Why does "activator ui" fail with "Error: Could not find or load main class ui"?

It's Typesafe Activator 1.2.10 on Windows 7, Scala 2.11.4, sbt 0.13.7. All packages installed using .msi.
When I run activator ui I get error:
Error: Could not find or load main class ui
and nothing happens then.
It appears that you're facing permission-related problems.
I can't give you the exact steps to sort it out (as I'm on Mac OS), but you should be able to work it around by running cmd as Administrator and then executing activator ui again.
There's also the version 1.2.12 so you may have more success with it. You don't need separate installations of Scala and sbt, either, as activator is going to take care of them (that's one of the many reasons to use the tool after all).

Achieve SBT Run startup speed while executing through command line

I've been working on a small set of command line programs in Scala. While
developing I used SBT, and tested the program with run within the console. At
this point the programs had a fast startup time (when re-run after initial compilation); nearly instant, even
with additional dependencies.
Now that I'm trying to actually utilize them on my system outside of sbt, the speeds have noticeable lag. I'm looking for ways to
reduce this, since the nature of these utilities requires little to no delay.
The best speeds I've achieved so far has been through utilizing Drip. I include all dependencies in a lib directory by utilizing Pack and then run by executing a shell script like this:
#!/bin/sh
SCRIPT=$(readlink -f "$0")
SCRIPT_PATH=$(dirname "$SCRIPT")
PROG_HOME=`cd "$SCRIPT_PATH/../" && pwd`
CLASSPATH_SUFFIX=""
# Path separator used in EXTRA_CLASSPATH
PSEP=":"
exec drip \
-cp "${PROG_HOME}/lib/*${CLASSPATH_SUFFIX}" \ # Add lib directory to classpath
TagWorkspace "$#" # TagWorkspace is the main class
This is still noticeably slower then invoking run from within SBT.
I'm curious as to why SBT is able to startup the application so much faster, and if there is someway for me to levarage its strategy, or SBT itself, even if that means keeping a long living process around to actually run a command through.
Unless you have forking turned on for your run task, this is likely due to VM startup time. When you run from inside an active SBT session, you have an already initialized VM pointing at your classes - all SBT needs to do is create a new ClassLoader and point it at your build output directory. This bypasses all of the other (not insignificant) stuff that happens when you fire up a new VM.
Have you tried using the client VM to start your utility from the command line? Sadly, this isn't an option with 64-bit Java, since Oracle apparently doesn't want to support it, but if you're using a 32-bit VM, try adding the -client argument to the list that you give the VM from the command line.
If you are using a 64-bit VM, some googling will find you some unofficial forks of OpenJDK that have the client VM re-enabled. It's really just a #define in the JVM build itself - it works fine once it's been compiled in.
The only slowness I have is launching SBT. Running a hello-word Scala app with java (no Drip) version 1.8 on a 7381 bogomips CPU takes only 0.2 seconds.
If you're not in that magnitude, I suspect your application startup requires loading thousands of classes, and creating instances of them.

How to run tests smoothly in Leiningen project within Counterclockwise/Eclipse?

I'm a newbie with Clojure and Counterclockwise and I succeeded adding a Leiningen 2 project with "Poor man's integration" (External tools, linked from question Using Clojure and Leiningen with IDEs).
My alternatives for running tests so far:
From command line : lein test
Running "lein test" with "Poor man's integration" (External tool)
These work pretty fine but I'm wondering whether there's some smoother alternative, for example showing the tests run like with JUnit etc?
Or with more general formulation, how to have fluent TDD flow with Counterclockwise?
Another alternative I found (with clojure.test API) was loading the test file in REPL (Alt+Cmd+S) and calling run-tests:
(run-tests)
With some trying, I can re-run the tests with my modifications by loading the modified file to REPL and calling run-tests again. (Works but isn't probably the final solution)
Midje with autotest in REPL seems to be worth checking out.
One way to do this is to use cljunit as an interface between the JUNit runner in Eclipse and your Clojure tests.

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.