I'm using espresso lib for android instrumentation tests. I also need to run precondition before tests (create account on web server, maybe some other data in future.)
I realized, that instrumentation test code actually runs on phone's JVM. I cannot run preconditions from phone, because of I'm planning to use jar-bundled test custom test framework where that precondition already implemented.
I there a way to run preconditions on PC JVM in android instrumentation test?
Related
There seem to be two approaches for invoking JUnit tests from the OS command shell:
java junit.textui.TestRunner <class-name>
and
java org.junit.runner.JUnitCore <class-name>
When do we use one versus the other?
Also, are there other ways to invoke Junit tests from the OS command shell?
JUnitCore is an entry point of JUnit - so if you want to run a test programmatically or of from some non-java script, I think, its the way to go for JUnit 4.
TestRunner is something a very old junit 3.x
Notice, that nowadays JUnit 5 is the latest available major release and it has yet another way to run the tests.
The question about different ways of running the tests from command line has been already answered Here so I can't add much to this.
However, I can comment on:
Also, are there other ways to invoke Junit tests from the OS command shell?
Nowadays in regular projects people do not run tests like this, instead they use one of build tools (Maven, Gradle for example) that among other things take care of tests.
So for example if you use maven, you can run mvn test and it will compile everything you need, including source code of tests, will take care about all test dependencies and will run all the tests with the help of build-in surefire plugin.
If you don't want to compile anything (assuming that all the code has been already compiled and all is set, you can use mvn surefire:test)
These build tools are also integrated with CI tools (like Jenkins, etc.) So this is considered to be a solved problem.
So unless you're doing something really different (like writing the IDE UI that should run test selected by user on demand or something) there is no really need to run tests with the options you've mentioned.
I have created several tests for a Polymer web component.
The tests are written according to the guidelines provided in polycast #36.
When I run the tests with Web-Component-Tester locally, all is fine and my tests pass.
When I run the tests in a local browser (chrome and firefox) all is fine.
I've also set up Travis-CI and Sauce Labs for automated testing.
Travis can run WCT locally in the shell. This works perfectly and my tests pass.
However when WCT is run with the sauce plugin enabled, and the tests are run on the sauce labs browsers, ONLY the async tests fail.
My test is waiting for a JS-event to be fired.
I presume the event is never received.
The output from WCT is not really helpful.
It just complains that the done() method is never called.
Does anyone else experience the same problems with WCT and Sauce Labs?
If so, does anyone have a solution for these async tests?
Edit 1:
I should add that my component wraps a native websocket.
The async tests wait for websocket events that are refired by the component after it catches the websocket event.
The issue might have something to do with Sauce Labs' SSL Bumping.
I could not figure out why the external connection fails when run in a Sauce browser.
The solution is to stub the websocket connection such that only the wrapper gets tested instead of the wrapper + websocket.
An aditional advantage to stubbing is of course that the tests run way faster.
I’m using Maven 3.2.3, SureFire 2.17, JUnit 4.11 and Eclipse Juno on Mac 10.9.5. I notice that when I run my JUnit tests via the command line
mvn test -Dtest=MyTest
the individual tests within the file “MyTest.java” run in a different order than when I run them in Eclipse (by right clicking the class name and selecting “Run As -> JUnit Test”). How do I get Eclipse to run the tests in the same order in which they are run on the command line?
Thanks, - Dave
The order of JUnit test runs are not guaranteed by design, as is mentioned in the JUnit FAQ page.This is done to promote the concept of test Independence, this will make sure that the tests will test their cases clearly and independently, and also ease maintainability.
This means that when you are running the tests in Eclipse, the orders are not guaranteed and keep changing. It's explained in "Can I change JUnit execution order?" on how you can possibly fix the order, even though its not a good practice.
I have a VS 2013 solution with a WP8 App, a WP8 Library for my viewmodels, a WP8 Unit Test project to test my library and other standard unit tests projects. The solution is under TFS 2012 source control, the build controller is setup and it correctly build my solution.
But my WP8 specific tests are not ran after automatic build. All other standard Unit Tests projects run well.
Some additional infos:
the ".xap" package for the test project is well generated
the build process Template (Default Template) is setup to use "Visual Studio Test Runner"
the build agent is running interactively
when i launch vstest.console.exe from the command line, giving the ".xap" package as argument, the test are well discovered and executed
I'am i missing something in the configuration ?
Windows Phone apps are currently not supported on Team Build, as documented here.
Feature | Windows Phone | Windows Store App
Team Build support | Not supported. | Includes support for running unit tests as part of Team Build.
There are a few unsupported work-arounds to solve your issue, more an be found here.
One of our test classes extends RemoteBaseTest but Jacoco ignores it completely.
How can I make Jacoco work with Sling Integration Testing?
For Unit Tests everything works as expected.
We are using Adobe CQ 5.6.1.
I see that this issue has been resolved: sling-issue-tracker-2810
but unsure how to implement it - is it even included in the latest CQ-Version yet?
If not how do I manually add it?
I don't know what RemoteBaseTest is but I assume you are running a JUnit "proxy" test which talks to the Sling JUnit server-side tests subsystem and causes the actual tests to run on your CQ server.
If that's correct, the actual test code doesn't run in the client JVM that's running RemoteBaseTest, it runs in the server JVM that's running CQ. So it's on the server JVM that you need to setup Jacoco to collect coverage data.
If you're running some tests on the client JVM (like common JUnit tests) and some on the server JVM via the Sling testing tools, Jacoco has functions to merge coverage data coming from different JVMs. We have this as a work in progress in https://issues.apache.org/jira/browse/SLING-1803 , which is not fully integrated in Sling yet but should be adaptable to any version of CQ.