1

I was wondering how RFT works even though it doesn't contain any public static void main(String[] args) in the script. The script contains a method public void testMain(Object[] args) which is running the script. Can someone explain how this is happening in RFT even though there is no public static void main?

user812786
  • 4,302
  • 5
  • 38
  • 50

2 Answers2

0

A Java program has not a fixed entry point. In fact, you can call any method you want, given it is accessible. What method is called is up to the application that is making the call.

What happens is that the java command line tool, as stated in the docs:

The java command starts a Java application. It does this by starting the Java Runtime Environment (JRE), loading the specified class, and calling that class's main() method. The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter.

This is just the java tool behaviour. Other tools can an do behave differently.

whbogado
  • 929
  • 5
  • 15
  • https://stackoverflow.com/questions/15173474/can-we-execute-a-java-program-without-a-main-method – Roland Jun 15 '17 at 11:22
0

There is no main() method because you don't run the RFT script as a Java application. You actually start some part of RFT which then calls the testMain() method. The RFT part you start contains a main() method. You can compare it with JUnit test cases: you run the JUnit framework and all your annotated test methods are called. In RFT you run the RFT part and your testMain() method gets called.

Roland
  • 1,220
  • 1
  • 14
  • 29