![]() That means if any test method in this suite takes more time than the specified time period (in this case 500 milliseconds) for complete execution, it will be marked as failed. This attribute will set a time-out period for test methods in the whole suite. In the preceding testng.xml file, a suite tag contains an attribute named time-out which has been set with a value 500. Now create a testng.xml file and put the following code to it. In the preceding program, a test class contains two test methods m1() and m2() which print messages on the console after successful execution.īoth test methods also contain Thread.sleep() method which pauses test execution for a specified amount of time in milliseconds. Public class void m1() throws void m2() throws InterruptedException Program source code 8: Time test at the suite level. Let’s create a test program and understand how this feature works. It will override the time period if you have configured it at the suite level. It can be achieved in two ways:Ī) At suit level: It will be applicable for all tests in the TestNG suite.ī) At each test method level: It will be applicable for each test method. ![]() In such a case we need to mark the test case as fail and then continue. It specifies a time period (in milliseconds) to wait for a test for complete execution.įor example, during running tests, there can be cases where certain tests may take much more time than expected. ![]() timeOut: The attribute timeOut is used for a time out test. It acts as a loop.įor example: = 5) // This method will execute 5 times.ġ1. invocationCount: This attribute is used to execute a method the number of times. For more detail, go to this tutorial: TestNG Groupsġ0. groups: It specifies the list of groups this method or class belongs to. This is because exception thrown by test method does not match with exception provided in the expectedExceptions list.ĩ. In the above program, a class contains two test methods exceptionTestOne and exceptionTestTwo which throws IOException and Exception respectively.Īs you can see from the test output, the test method exceptionTestTwo() has been marked as failed by TestNG during execution. Public void exceptionTestTwo() throws Exception If any test method belonging to a particular group is failed, the dependent test method will not be run and will be flagged as a SKIP. We can also specify a list of groups this method depends on.Īll of the methods of these groups are executed first before this method. dependsOnGroups: This attribute is used to make test methods depend on a particular group. Where, Hello is the name of class where DataProvider method has been declared.Ĥ. = "getData", dataProviderClass = Hello.class) dataProviderClass: This attribute is used to call the DataProvider method from another class. ![]() dataProvider: This attribute is used to provide data to the test method directly in data-driven testing. Program source code 2: package testAnnotation Ģ.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |