Working with TestNG - Starters Guide
Chapters
How to ignore a test in testNG
In some situation user need to ignore the test case to achive this TestNG provides an annotation @Test (enabled=false) which disables the test case from execution process.
Create a Class:
This class having three test cases (TestCase1, TestCase2, TestCase3
) where one case ignore (TestCase2
) by using annotation "@Test (enable=false)
"
package testNG; import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; public class TestNGIngore {@Test public void TestCase1() { System.out.println("inside the TestCase1"); String msg = "Welcome to TestNG"; assertEquals("Welcome to TestNG", msg); } @Test(enabled = false) public void TestCase2() { System.out.println("inside the TestCase2"); } @Test public void TestCase3() { System.out.println("inside the TestCase3"); } }
Run above class by clicking on run button in eclipse
The Output
You can see that our TestCase2 was not entertained. This was possible because of the attribute enabled=false, which tells testNG to skip this test.
Description
This tutorial is focused on getting you started on TestNG, the testing framework inspired from JUnit and NUnit. Here is a quick table of contents
- What is TestNG?
- Environment Set-up
- Writing Tests
- Basic Annotations
- Execution Procedure
- Executing Tests
- Suite Test
- Ignore Test
- Group Test
- Exception Test
- Dependency Test
- Parametrized Test
- JUnit Tests
- Test Reports
- Running tests without Eclipse
- Plugin with ANT
Environment
A computer capable of running Java. IntelliJ Community IDE is also required for this course.
Prerequisites
Good knowledge of Java programming language and eclipse is essential.
Audience
Students looking to get started with TestNG
Learning Objectives
This tutorial will get you started with TestNG.
Author: Subject Coach
Added on: 12th Mar 2015
You must be logged in as Student to ask a Question.
None just yet!