Automation of Test Case with TestNG and
Eclipse
I willTalk about concepts, creating,
structure and execute through xml files to automate the test cases using TestNG
TestNG:
TestNG is a test framework desigined to simplify a
broad of testing needs, from unit test, integretion testing.
In order to Write a test with TestNG, you need
three step
- You need write the business of your test and insert TestNG annotation in your code.
- Add the information about your test (class name or group to run) in a testng.xml file
- Run TestNG.
For automation of Test Case, first you need to
follow steps of my own last post
TestNG has the followings Annotation
@BeforeSuite
@AfterSuite
@BeforeTest
@AfterTest
@BeforeGroups
@AfterGroups
@BeforeClass
@AfterClass
@BeforeMethod
@AfterMethod
@AfterSuite
@BeforeTest
@AfterTest
@BeforeGroups
@AfterGroups
@BeforeClass
@AfterClass
@BeforeMethod
@AfterMethod
In this example we will use the followings
@BeforeTest: The annotated method will be run before any
test method belonging to the classes inside the <test> tag is run.
@Test: The annotated method will be run test method.
@AfterTest: The annotated method will be run after all the test methods belonging
to the classes inside the <test> tag have run
Int this example is using dependsOnMethods, is the list of methods , this methods, we are
guaranteed that all these methods will be run before the test method that
contains this annotation is run. Furthermore, if any of these methods was not a
SUCCESS, this test method will not be run and will be flagged as a SKIP.
We will use a xml file, so we will call to our
class. For example firstTestNG.java
First Test Case with TestNG
Following the steps
1. Creating of new project
2. Add package a this class
3.Create a new class for this project
4. Add the Annotations for the test case
5. The test case finished
6. Create xml file for run the test cases.

















No hay comentarios:
Publicar un comentario