Running Junit in both Eclipse and unix - java

I know this is basic Java Eclipse question. But, if I create Junit test cases from Eclipse and be able execute them in Eclipse.
Can I also take same test cases in run them in unix/linux envirnment? Do I need to set different in eclipse in order to run them in unix/linux envirnment?
Thanks.

The Java Virtual Machine (JVM) is fully platform-independent. Any JUnit tests that work on one OS, such as Windows, will work on another, such as Linux.
To run a JUnit test inside UNIX/Linux, you can:
Install and run it from Eclipse, just like you would on any other OS (Eclipse, being built in Java, is also platform-independent).
Run java org.junit.runner.JUnitCore test class in the terminal, where test is the name of the test you want to run, and class is the class that that test resides in.

Related

How can I see the actual commands (java) running in Intellij Idea?

I use IntelliJ IDEA CE in two environments (CentOS and Ubuntu).
The two share a project via GitHub.
In CentOS, the project is regarded as Java project? with a file build.gradle.
In the other, the project is fully managed as Gradle-Java project.
When I run a main method in CentOS, IDE just runs Java (after some compiles if are required)
On the other hand, when I run the same main method in Ubuntu, IDE activates Gradle and run that.
I think this difference happens from the module structures.. which I have not tried though....
(Am I wrong?)
One question I really want to know here is,
in CentOS, when I run a code, it shows how IDE ran the code in the Run window, like...
java [too many options] foo.target.Hoge
If I copy and paste this line, I can activate foo.target.Hoge anywhere, even where I do not set CLASSPATH because [too many options] contain that.
I always do it (I am afraid if I should not though)
However, in Ubuntu (Gradle-based environment)
the windows show only
time PM: Executing task 'Hoge.main()'...
I can not copy, paste and run it...
I want to know where I can found the actual command activated.
or.... using Gradle.. are there any simpler ways?? like
gradle run Java Hoge ...
When I run a main method in CentOS, IDE just runs Java (after some compiles if are required) On the other hand, when I run the same main method in Ubuntu, IDE activates Gradle and run that.
For Gradle-based projects this behaviour is controlled in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using option. When Gradle is set IDE uses Gradle to run and build the project. When IntelliJ is set IDE uses it's own builder and Run/Debug Configurations to run.

automatically run external application, which use Cucumber for testing main application

We have application which use Cucumber framework for testing our second application, the applications runs on own processes (black box testing), currently we do following steps:
1) Run DB
2) Run main application
3) Run test application which use Cukumber framework for testing main application
Question is: how we can do this automatically by using TeamCity ?
Create a Command Line build step:
Point to the working directory
Run your Cucumber tests from the command line. Example.
Here is more info on Cucumber's CLI.
My approach would be to write a script that sets up all dependencies. I.e. starting the database, starting the second application and then run the Cucumber stuff. The script would be possible to run on the CI server, i.e. TeamCity or on a developers system so it is easy verify that they didn't break anything before committing.
Restricting the execution to TeamCity only would not be my preferred approach.
This lead toa solution taht depends on your dev and CI environment. Are you running on Windows or on Linux? The scripts will different depending on the operating system.

Run Java TestNG test from .Net

I have created a java project to run automated test cases for native app using appium and selenium.
Now our clients want to run that java project through .NET.
I have tried using ikvm.net but it says "Manifest doesn't contain a Main-class" because testNG class doesn't contain main class.
Can anybody suggest another way to achieve this?
As testng is for java you can do something like this:-
You can create a bash file for testng which is execute testng for java
Refer:-
http://stackoverflow.com/questions/32120102/bash-file-is-running-fine-in-windows-for-testng-but-it-is-not-working-in-linux-m
Now you need to execute that bash from a C# code
http://raspberrypi.stackexchange.com/questions/9474/how-can-i-run-a-terminal-command-bash-from-c-mono
Hope it will help you :)

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