Running TestNG unit test in Eclipse ignores latest changes - java

I have a maven-based Java project, which contains many unit tests. These unit tests take a long time to execute, so I'm trying to execute only a specific test class via the TestNG Eclipse plugin.
Running the test the first time works as expected, but if I make any changes to the test class and try to re-run it, I get the same result as the previous run. Basically, my changes to the test class are ignored and the test is executed using a previously compiled test class.

The project had several unrelated errors (visible under the Problems view). Once those errors were resolved, the test class was automatically compiled and changes were picked up in subsequent executions of the unit tests.

Related

How can you tell if you are running a JUnit test through maven vs eclipse programatically?

Scenario:
I have a JUnit test with SysOut calls.
I want to suppress these calls when maven is executing in order to reduce clutter on the screen.
However, I'd still like it to print out when run through Eclipse.
Is there a way to check programmatically if the Maven is the one executing the JUnit test?
Pseudo-code:
if (!isCalledByMaven()) {
System.out.println("Bob is not here.");
}

How to run java class as a JUnit test through command line

So I am making an eclipse project with cucumber and selenium in order to automate execution of some test cases.I have a runner class,which can be executed as a Junit test and lead to execution of all feature files consecutively.
My question is can I execute this runner class through windows 7 cmd.
The idea is to make a script(cron job/scheduled task) who can trigger tests execution at given time.
Follow this to see how you can schedule it:
http://www.digitalcitizen.life/how-create-task-basic-task-wizard. Not pasting the contents of this article since it contains a lot of images.
In the scheduler, go to the directory, and run mvn test -Dtest=com.package.ClassName

Running a subset of tests in Gradle

I have a multiproject gradle build which contains a mix of Java with JUnit and Scala with Specs tests, plus a few other technologies.
I have pretty much everything building fine but I am hitting an issue with the tests.
My projects are all organised with the following structure
<project>/src/main/... - containing the production source code
<project>/src/tests-unit/... - containing the JUnit or Specs test code
and then optionally a combination of
<project>/src/tests-util/... - containing utility classes for setting up tests
<project>/src/tests-functional/... - containing functional level test code
<project>/src/tests-integration/... - containing integration level test code
My problem is that running grade tests on this project will actually run the tests in all the test directories and I want to be able to control what tests are being run. I had the idea of setting up a separate task for each level of test, but how do I specify to just run tests in the /src/tests-unit hierarchy and ignore the others?
I have tried several things including setting the runtimeClasspath of the sourceset for a target but I just get a deprecation warning for this and it has no effect.
Many thanks
You'd typically declare separate source sets and separate Test tasks. See samples/java/withIntegrationTests in the full Gradle distribution for details.

Is it possible to run Eclipse application and Junit plug-in test simultaneously?

I have an eclipse application, where in i can create projects and perform some operations. I have written a test cases using Junit for some functions. To run these test functions, i am doing Right click on test class and Run as Junit Plug-in test and it is working properly. I am unable to do both the things at the same time. What i need is to run my eclipse application and Junit plug-in test simultaneously without human intervention. Junit plug-in test has to be done at run time. If there is a way to do that, then please suggest me the solution.
When you run it as Junit plugin test, then it already launches your eclipse plugins (and application), so there is absolutely no need to try to launch an additional application.
What probably confuses you, is that the test run and the "normal" manual run use two different workspaces. So if you try to access some files in your test which you created during normal operation, they will not exist. But you should never rely on such things, instead you have to create the necessary artifacts in the test setup method.

how to run playframework FunctionalTest through Eclipse?

and the second question:
is it possible to run them all in a bunch through Eclipse?
One approach could be, Install 'antify' module and run 'play antify' on your application. It will create a build.xml for your app (which would import the needed targets from application-build.xml file) and run 'auto-test' from eclipse.
FunctionalTest and UnitTest extend BaseTest, which is annotated with the PlayJunit4TestRunner, so you should find that you can just run tests as you would with any other test (i.e. Run As > Junit Test). You'll see the Play environment being initialised on the console before the tests actually run.
One problem I've found is that running a whole package of Play tests in Eclipse is buggy, so I tend to just run one at a time in Eclipse and then use Play's own testrunner to verify the whole suite.

Categories

Resources