Selenium is a tool that employs Javascript in order to take control over your browsers and simulate web surfing activities. Therefore, Selenium is able to replicate any action typically undertaken by a user, such as clicking, typing and retrieving data from web pages.

When combining Selenium with other testing frameworks such as JUnit or TestNG, you are getting a very powerful and complete testing framework for web applications.



  • Apache is installed.
  • PHP is installed.
  • MySQL is installed.

To check if you have all the requirements, do the following steps:

  1. Paste <?php phpinfo(); ?> into a text editor and save as info.php
  2. Copy info.php into the root directory of the webserver(eg. htdocs folder)
  3. Open with an web browser You should see PHP Version X.X.X and MySQL Support. Otherwise, some requirements are not installed.

TestNG - Execution order of TestNG's annotations

Codes below show the execution order of commonly used annotations of TestNG.


TestNG is a java testing framework. It was created by Cédric Beust out of frustration over JUnit's deficiencies. It was designed to cover all categories of tests such as unit, functional, integration, etc.

The idea is very simple. It is breakdown into the following steps:

  1. Create your class.
  2. Create test scenarios by using methods of your class and then you have to implement the logic to check whether the methods behave correctly or not. If they do, then tell TestNG that it is good. Otherwise, tell it it is bad.

JUnit - Parameterized Tests

Sometimes you want to use a generic test method to test with different sets of values. But if you use a loop to do that, then the whole method will fail if 1 of the set of values fails. As a result, it is not helpful as you don't know which specific set of values failed. JUnit report will only show that the generic test method as a whole failed. But if you are writing 1 test method per set of values, then there is a lot of codes, which is not efficient and practical.

JUnit - Execution order of JUnit's annotations

 * Show the execution order of each annotations.
 * Given this test, the methods will execute in the following order:
 * oneTimeSetUp()
 * setUp()
 * testMyFunction1()
 * tearDown()
 * setUp()
 * testMyFunction2()
 * tearDown()
 * oneTimeTearDown()
 * **NOTE**: JUnit doesn't guarantee the execution order of the test functions(@Test).
 * @author: Xuan Ngo
import org.junit.*;
public class JUnitCheatSheet
  public static void oneTimeSetUp()
    // one-time initialization code


JUnit is unit testing framework for the Java programming language. It allows you to easily verify the individual unit of source code through assertions.


Subscribe to RSS