Annotations
@Test
write a test
@BeforeClass will be called very begining of all functions
@AfterClass will be called end of all functions
These aove 2 annotations should be Static in nature
@after
@Before : this fucntion will be called before calling each and every test
@After : this fucntion will be called after calling each and every test function
Order doesn't matter...where ever you write it will be executed in order
@Ignore : the function will be skip the execution
Assume.assumeTrue(false) : no test method (@Test) will be called
Parameterize:
step1:
@RunWith(Parameterized.class)
Step2:
Initialise variables
Step3:
create Constructor
step4: function @test
Step5: @Parameters
public static Collection<Object[]> getData(){
Object data[][]=new Object[2][2];
//1st row
data[0][0]= "xxx";
data[0][1]= 4566;
data[1][0]= "vv";
return Arrays.asList(data);//standard returning type
Assertions and error reporting:
Error Collector- declare this object as global
@Rule
public ErrorCollector errCol= new ErrorCollector();
try{
Assert.assertEquals("Hello", "Hello122");
Assert.assertTrue("error", 3>7);
}catch(Throwable t){
//System.out.println("error "+t);
//report error
errCol.addError(t);
Batch test: to run more than 1 at a time
use annotation,
@RunWith(Suite.class)
@SuiteClasses({
and then give all classes like xxx.class,xxx2.class,xxx3.class and run...
@Test
write a test
@BeforeClass will be called very begining of all functions
@AfterClass will be called end of all functions
These aove 2 annotations should be Static in nature
@after
@Before : this fucntion will be called before calling each and every test
@After : this fucntion will be called after calling each and every test function
Order doesn't matter...where ever you write it will be executed in order
@Ignore : the function will be skip the execution
Assume.assumeTrue(false) : no test method (@Test) will be called
Parameterize:
step1:
@RunWith(Parameterized.class)
Step2:
Initialise variables
Step3:
create Constructor
step4: function @test
Step5: @Parameters
public static Collection<Object[]> getData(){
Object data[][]=new Object[2][2];
//1st row
data[0][0]= "xxx";
data[0][1]= 4566;
data[1][0]= "vv";
return Arrays.asList(data);//standard returning type
Assertions and error reporting:
Error Collector- declare this object as global
@Rule
public ErrorCollector errCol= new ErrorCollector();
try{
Assert.assertEquals("Hello", "Hello122");
Assert.assertTrue("error", 3>7);
}catch(Throwable t){
//System.out.println("error "+t);
//report error
errCol.addError(t);
Batch test: to run more than 1 at a time
use annotation,
@RunWith(Suite.class)
@SuiteClasses({
and then give all classes like xxx.class,xxx2.class,xxx3.class and run...