TestNG Category

TestNG with Cobertura – generate code coverage report

Cobertura is a open source coverage tool which calculates the percentage of code accessed by test and generate source code coverage report.

TestNG Tutorial and Example – Suite Test

A test suite is a collection of test cases that are intended to test a behaviour or set of behaviours of software program. In TestNG, we cannot define a suite in testing source code, for better, it is represented by one XML file, because suite is the feature of execution, this also allows flexible configuration […]

TestNG Tutorial and Example – Dependency Test

Dependency is common need in unit testing, because the test cases may share some state, data and conditions, in order to write repeatable cases and run them in isolation, TestNG supports the declaration of explicit dependencies between test methods, it is enabled with two attributes of the @Test annotation, dependsOnGroups and dependsOnMethods.

TestNG Tutorial and Example – Group Test

The group test is a new innovative feature in TestNG, it doesn’t exist in Junit framework, it permits you dispatch methods into proper portions and preform sophisticated groupings of test methods. In TestNG, you can declare one method belong to one or more groups, even a certain set of groups can be included or excluded in groups.

Testng eclipse tutorial – Install and use testng eclipse plugin

The TestNG Eclipse plug-in allows that we run TestNG tests from inside Eclipse in a convenient way. once we draft test case then we would’t need waiting, simply run it from Eclipse and monitor the execution and output. This tutorial will guide how to install TestNG eclipse plugin, write and run test case with this plugin.

Eclipse plugin Cobertura, Clover and Eclemma for TestNG coverage

TestNG is a popular Java testing framework, Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. it is mostly we used Eclipse as IDE and TestNG as Unit testing framework. So that is helpful to use Eclipse plugin to help us analyze code coverage for TestNG […]

TestNG tutorial – Time Test with Annotation Timeout

Some test cases may expect longer time to excute, in order to avoid take more than the specified number of milliseconds or not to block TestNG forever, we specify a timeout in the @Test annotation, if a unit case takes more than the expected time, ThreadPoolExecutor will be interrupted and test case will be terminated and mark […]

TestNG tutorial – Ignore Test

Annotation @ignore in TestNG allows a test to be deffered until it is ready (or the feature is). In TestNG, you can use annotation @Test(enabled = false) to bypass one test case if it is not ready to test. package com.asjava; import org.testng.annotations.*; public class TestNGIgnoreTest { @Test(enabled = false) public void testsetProperty() { String path […]

TestNG Tutorials – Expectedexception Test

This is a consequence of the fact that exceptions are expected in a unit case. What is traditional testing design pattern to do Expectedexception test? package com.asjava; import org.testng.Assert; import org.testng.annotations.Test; import java.util.List; public class TestNGExpectedExceptionTest extends Assert { @Test public void testNullPointerException() { try { List list = null; int size = list.size(); fail(“The test […]

TestNG Basic Concepts and Annotations

TestNG engine supports a series of annotations, with these annotations it even has stronger flexibility and extensibility than Junit, we will learn these annotations from this tutorial,  first of all, let us take a quick view the life cycle of a typical TestNG case.