TestNG

TestNG Tutorials

Mockito Stub Exception – JUnit, TestNG

Sometimes our methods throw exceptions and we want to mock the object and test the exceptions. We can use Mockito mock objects with when() and thenThrow() to mock this scenario. Mockito Stub Exception – JUnit….

TestNG Mockito Example

In the Mockito Tutorial, we used JUnit to run test cases. Mockito framework can be combined with other Java testing frameworks too. In this tutorial, we will integrate Mockito mocking framework with TestNG testing framework…..

JUnit vs TestNG

JUnit and TestNG are the most popular testing frameworks for Java applications. Both of these frameworks are really good and easy to use. So when it comes to chose the testing framework for your application,….

TestNG Annotations

TestNG annotations helps us in quickly writing test cases, configure them programmatically. Let’s have a look at the most important TestNG annotations. TestNG Annotations – Configuration TestNG provides following annotations for configuring our test suite….

TestNG Dependency – dependsOnMethods, dependsOnGroups

Sometimes we want our test cases to run in specific order. One of the very common examples is when we want to run test cases for CRUD operations. So we want to make sure that….

TestNG Groups

TestNG Groups is one of its very important and useful features. We can specify groups for TestNG methods, it can be used with @Before, @After and @Test methods. TestNG Groups Once we have defined the….

TestNG Timeout Example

We can specify a timeout for our TestNG tests. This can be done in the test class by setting timeOut property of @Test annotation. When the test methods doesn’t finish in the specified timeout, org.testng.internal.thread.ThreadTimeoutException….

TestNG Parallel Execution

We can run TestNG tests in parallel. This feature is only available when we are using TestNG XML suite for executing our test cases. TestNG Default Tests Execution When we run TestNG class, methods are….

TestNG Ignore or Disable Tests

Sometimes we want to ignore a TestNG test method, there are many ways to achieve this. TestNG @Test enable parameter We can disable or ignore a test method by adding enabled=false to @Test annotation. Let’s….

TestNG Exceptions – expectedExceptions, expectedExceptionsMessageRegExp

Sometimes we want to test our methods for exceptions. TestNG allows us to perform exceptions testing using expectedExceptions and expectedExceptionsMessageRegExp parameters of @Test annotation. TestNG expectedExceptions Let’s say we have a simple utility method for….

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages