Organize and manage test cases with TestNG
TestNG is a unit testing system like JUnit. Be that as it may, TestNG has more elements. When coordinated with selenium,Guest Posting you can put together and deal with your tests all the more effectively. With a large number of comments given by TestNG, you can accomplish gathering, sequencing, prioritization, definition of your experiments alongside audience interfaces, where you can play out many procedure on a specific occasion. It additionally enables us to perform equal execution of our experiments through xml. You can make various XML suites like relapse suite, mental soundness suite, smoke suite, and design these suites in the fundamental testng.xml.
We’ll see individually how these can be accomplished through TestNG.
Composing and executing first TestNG test
In TestNG we use @Test comment to characterize our test technique or experiment. So a technique on which @Test explanation is composed is our experiment or test strategy. In this technique, you will play out the test execution and perform approval for example whether the genuine outcome is coordinating with anticipated utilizing affirmation. To execute this test strategy, you really want to characterize the test class in which this test technique is written in testng.xml.
1. Gathering
Assume you have different test classes and those test classes have various test techniques in them. Presently you need a couple from each class ought to be executed and not all in light of your test plan. Here gathering comes into the image where you can bunch your experiments/test techniques having a place with various test classes. For example you have a relapse suite and a smoke suite. You need a couple of sets of test techniques gets executed during smoke suite execution and one more arrangement of test strategies during relapse. Here there is a test class considered subMenuPageTest, inside which there is a test technique called checkProductClick(). As you can see from the beneath picture, this test technique has a place with “smokeTest” bunch.
In the resulting picture there is our testng.xml where we have incorporated the gathering “regressionTest” in our test tag.
This implies execute just those test techniques from class subMenuPageTest which has a place with “regressionTest” bunch. So when we execute this xml, just those test strategies from class subMenuPageTest will be executed which has a place with the relapse bunch and not the ones which have a place with the ‘smokeTest’ bunch.
2. Sequencing
The sequencing of test techniques can be accomplished through the ‘need’ characteristic under @Test explanation. In the event that you have different test strategies in your test class and you need your experiments/test techniques to execute in a specific request or grouping then you can utilize need characteristic with @Test explanation. Zero is the most noteworthy need.
3. Definition
You might need to execute your tests with various arrangements of boundaries. For example you need to execute your tests on a specific program, or on a specific operating system, or on a specific climate like test, QA, UAT and so on, on nearby climate, or on cloud and so on.
For this, you can characterize a strategy tolerating these boundaries and in light of the boundaries your condition will be executed. In the beneath picture you can see there is a technique which is tolerating two boundaries ‘program’ and ‘climate’. In light of these boundaries, the separate circumstances will be conjured ie. in the event that you pass program as ‘chrome’ and climate as ‘nearby’ separate ‘if’ condition will be executed and chrome driver setting with neighborhood webdriver introduction will occur.