Best Practice For Writing A Test case
  • Make sure your test case steps handle the timeout specified in the step configuration. For example, a test case connecting to a web server should make use of the timeout in order to get a response from the server within the configured timeout.
   public Result executeConnectToServer(TestCaseStepConfiguration config)
      Result result = Result.createOK();
      // Get configuration for this action
      String serverIP = config.getProperty("serverIP");
      String serverPort = config.getProperty("serverPort");
      // Timeout as specified in this step's configuration
      long timeout = config.getTimeout();
      socket = getSocket();
      socket.connect(new InetSocketAddress(serverIP, serverPort), (int)timeout);
  • If you use class member variables/methods (static) in your test case, make sure that they are proper synchronized. Multiple threads may execute class member variables/methods concurrently.
  • For stateful test cases, be aware of that its methods may be executed concurrently.
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.