2

I wrote a TestRails.java class with a main method that uses TestRails JAVA API Binding classes. I’m trying to compile and run it in the Jenkins build shell section. Is this not the way I’m suppose to integrate Jenkins with TestRails? I'm new to coding and this is first time writing code to interact with an api. I appreciate advice from other more experienced coders and testers.

I’m getting main method not found when running TestRails java file with a main method in command line that depends on TestRails Java API Binding classes without a main method. How do I fix this? I can’t change APIClient.java and APIException.java since those are not suppose to have a main methods.

I'm new to coding and this is first time writing code to interact with an api. I appreciate advice from other more experienced coders and testers.

java -cp ../../../ com.gurock.testrail.APIClient -cp ../../../ com.gurock.testrail.APIException -cp ../../../ com.gurock.testrail.TestRails BeforeRun /Users/abc/.jenkins/workspace/IOSPredeploy/AppiumTest/src/test/java/com/gurock/testrail/input_test_rail.xml 20190314

Error: Main method not found in class com.gurock.testrail.APIClient, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application

asked Mar 14, 2019 at 21:16

2 Answers 2

2

Try this:

java -cp ../../.. com.gurock.testrail.TestRails BeforeRun /Users/abc/.jenkins/workspace/IOSPredeploy/AppiumTest/src/test/java/com/gurock/testrail/input_test_rail.xml 20190314
answered Mar 14, 2019 at 21:28
1
  • Getting this error Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONValue at com.gurock.testrail.APIClient.sendRequest(APIClient.java:138) Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONValue Commented Mar 14, 2019 at 21:34
2

The Java API binding expects an object or array argument instead of a string. The binding would then automatically serialize this to a JSON string. An example for this can be found here:

http://docs.gurock.com/testrail-api2/bindings-java#examplepost_request

answered Mar 15, 2019 at 6:24
1
  • Thanks. I realized where I went wrong. I am suppose to write code to call my class that uses the TestRails API java bindings inside my automation framework and not to run this class in the build section of Jenkins. My approach was wrong. Ignore this question, this is no longer relevant. I am able to integrate TestRails with Jenkins after I used the new approach. Commented Mar 18, 2019 at 17:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.