Build jar file after junit test pass - junit

I want to build jar files when all test cases pass and when 1 test case fails then not build jar files.
Please help me config
I use java8,junit5,junit jupiter 5.8.2,junit platform 1.8.2

Related

I am working with JDBC, and I have used mysql-connector 8 to run my java program from command line

When I am compiling the Java code, I have written the command line shows the following:
C:\HTML>javac Jdbc.java
Jdbc.java:5: error: package com.mysql does not exist
Class.forName(com.mysql.jdbc.Driver);
^
1 error
I have installed XAMPP and started the Apache, MySQL and Tomcat and they are working. I have installed MySQL Connector which is platform independent and latest. I have copied the JAR executable file to the JDK folder. I have added the jar executable file path in the edit system environment variables,
''' Class.forName(com.mysql.jdbc.Driver);'''
If you reference classes from a library, you should add that library to the classpath (i.e. javac -cp .;path\to\your\mysql-connector.jar Jdbc.java). However, that would immediately result in a different error, because that code should be Class.forName("com.mysql.jdbc.Driver") (passing a String).
Some further remarks:
I have copied the JAR executable file to the JDK folder.
You should never manually copy files to the JDK folder (in older versions there was the ext mechanism, but this no longer exists in recent Java versions). In addition, MySQL Connector/J is a library, not an executable jar.
I have added the jar executable file path in the edit system environment variables
Java JARs do not belong on the PATH. In theory you can add them to CLASSPATH environment variable, but that is generally considered a bad idea: most ways of executing Java do not actually use it, and if it does get used, it can result in unexpected behaviour because of conflicting or unexpected libraries on the classpath, etc.

Create executable jar from JUNIT 5 without maven/gradle

How do I create an executable jar for my JUnit 5 test class without maven/gradle/etc.?
If I try Eclipse Junit Class -> Export -> Java -> Runnable Jar the jar file produced will not run, it says main method is needed. However, the testRunner examples I've found online are all for JUnit4 and have compatibility issues with JUnit 5.

Visual Studio Team Services Building JSON Scripts

I'm currently building scripts using Selenium Builder (which saves files as JSON) and i'm having a hard time running these scripts on VSTS. My question specifically is, can Visual Studio Team Services build JSON scripts and tie them in with its C.I.? If so, which approach must I take in order to do this / make it possible?
Thanks!
Here is my steps for your reference:
Deploy your own private build agent by following this link.
Configure the required environment on the build agent like Selenium Driver, Firefox so that the testing can be run on the build agent.
Upload the json file generated by Selenium Builder into VSTS Repository.
Create a build definition with two Command Line tasks: The first one runs npm install command to install se-interpreter:
And the second one run se-interpreter command to run the test in json file:
Queue the build, you will see the test been executed during the build:

Is there any command or way to find out the location of my JUnit?

i have a MacBook Pro and have downloaded java version 1.8 and selenium also. But im unable to find JUnit. Can i get the command to check the location of my JUnit. I have tried using a code to check whether JUnit is installed and the output is successful.
JUnit is not part of the standard JDK content; same for selenium.
Thus: you have to do something to pull the JUnit jar to your system. Either by downloading it manually yourself; or by using a build system like Maven or Gradle that can take care about resolving "dependencies" and downloading required artifacts automatically for you.
But in order to locate jar files on your system, you can simply turn to find command, like:
find / -type f -name "*.jar"
which should list you JAR files existing in your file system. You can read here about this and other tools that help you find files in your file system using the command line.

Junit reports for Hudson

I am able to successfully run my JUnit test suite from the command line and now I want run these tests from Hudson.
However , for Hudson to generate the reports , it needs a results file (I think in xml format) .
How do I generate a results file from JUnit ?
I am using the following command to run the tests :
java com.nvidia.tests.TestSuite1
Thanks in advance .
Parag.
If you're using ant, you can look at the JUnit task for ant. This is probably the easiest way. You can just add the task at the appropriate place in the script.
If you're using maven, look at the surefire plugin for maven which will automatically run the tests and create the reports in jenkins.
EDIT: If you're not using any build tool (which you should be), then just add the ant build script to jenkins, and you should get the reports automatically.