Similar as Junit, TestNG has annotations. Now below is the example , in which i am using two annotation one is @test and other one is @configuration(beforeTestclass) . you should keep in your mind, as the name implies of the annotation , its corresponding functions executation are also depend on its annotation.
in the below example i am writing @test annotation method first and @beforetestclass annotation after that. After execution what should be its result :-
Example
-----------------------------------------------------------------------
import org.testng.annotations.Test;
public class Readdata_From_Excelfile {
@Test(groups = { "functest" })
public void serverIsRunning() {
System.out.println("serverisrunning");
}
@Configuration(beforeTestClass = true)
public void init()
{
System.out.println("init function");
}
}
Result is :-
init function
Serverisrunning
in the below example i am writing @test annotation method first and @beforetestclass annotation after that. After execution what should be its result :-
Example
-----------------------------------------------------------------------
import org.testng.annotations.Test;
public class Readdata_From_Excelfile {
@Test(groups = { "functest" })
public void serverIsRunning() {
System.out.println("serverisrunning");
}
@Configuration(beforeTestClass = true)
public void init()
{
System.out.println("init function");
}
}
Result is :-
init function
Serverisrunning
No comments:
Post a Comment