executing a java class file from ant script - java

I need to run a java class (actually a test case) from ant script. Is it possible to do so?

At the most basic level you could use the ant java task to do this.
But you tagged with junit4 - can you not use the ant junit task?

To execute java class, you can use java task http://ant.apache.org/manual/Tasks/java.html
To execute junit test cases: http://ant.apache.org/manual/tasksoverview.html#testing

Try the java task. If you want to run tests, you might want to take a look at JUnit

Related

Is it possible to start a test run of a JUnit 5 test class from within Java?

I found instructions on how to start a JUnit 4 test case from within Java, but have been unable to put together constructs that will fire up tests on a JUnit 5 test case.
The JUnit 4 solution I tried was this: How do I run JUnit tests from inside my java application?
I've been trying to get the ConsoleLauncher in JUnit5 to work, but it is throwing exceptions. That was documented here: http://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher
I'd like to automate starting tests to match running a program to simplify the instructions I'm providing when I provide unit tests to students.
Thanks!
If the goal is to simplify a task for students, I think it would be good to use a build tool like Maven or Gradle. This makes it simple to run tests, build their code, etc. JUnit5 tests can be run by using plugins - http://junit.org/junit5/docs/current/user-guide/#running-tests-build.

executing a testng java test with python for junit results

Hi and thanks in advance,
I have several scripts in python(2.7+) which produce junit test results. Currently I am trying to leverage some java testng code. I was wondering if there is a way to use python to execute java testng code while including it in a junit test suite. I am aware that testng produces a junit reports folder.
Note for the python junit scripts, I am using xmlrunner to produces the results.
A solution may be to call a command prompt from your python code which calls the prompts to execute the java environment. To call TestNG or JUnit for example, you just have to call the specific jar file from the lib.
import subprocess
proc = subprocess.Popen("java...", shell=True, ...)
You can catch the returncode to check if the tests where executed correctly.

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 subclass an ant task?

I wrote an ant task to run my project in NetBeans (I'm using a freeform java project). Now I want to write a debug task. The debug task is nearly identical to the run task except for a few added properties. Can I subclass the run task and add in the extra properties?
Since an Ant task implementation is a Java class, Ant tasks may be subclassed just like any other Java class. However, the usual method for testing tasks is to write both JUnit and AntUnit tests.
For examples, take a look at the Apache Ant source code under tests.

JUnit Tests - Is a call to JUnitCore.main() necessary?

Good afternoon,
I am running some JUnit tests on my application using ant. In doing so I am following the instructions in the step-by-step Spring-MVC tutorial. [*]
The instructions never mention a call to org.junit.runner.JUnitCore.main() in running a test. My question is, is it necessary to call org.junit.runner.JUnitCore.main to run a test if you are running the tests through command-line ant (as opposed to an IDE)? Or is ant smart enough to locate all the methods in a TestCase subclass and run all of them without an explicit call to JUnitCore.main()?
[*] http://static.springsource.org/docs/Spring-MVC-step-by-step/part3.html
Thanks,
ktm
Ant knows what to do. As long as you're using the right ant-task for that (like jUnit task: http://ant.apache.org/manual/Tasks/junit.html).

Categories

Resources