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

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
  • 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 – seleniumappiumnewbie Mar 14 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

  • 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. – seleniumappiumnewbie Mar 18 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.