Home | History | Annotate | Download | only in sample
      1 package test.sample;
      2 
      3 
      4 import org.testng.Assert;
      5 import org.testng.annotations.AfterClass;
      6 import org.testng.annotations.AfterMethod;
      7 import org.testng.annotations.BeforeMethod;
      8 import org.testng.annotations.ExpectedExceptions;
      9 import org.testng.annotations.Test;
     10 
     11 /**
     12  * This class
     13  *
     14  * @author Cedric Beust, Apr 26, 2004
     15  *
     16  */
     17 public class Sample1 extends BaseSample1 {
     18 	@AfterClass
     19 	public static void tearDownClass1() {
     20 	}
     21 
     22 	@AfterClass
     23 	public void tearDownClass2() {
     24 	}
     25 
     26 	@BeforeMethod
     27 	public void beforeTest() {
     28 	}
     29 
     30 	@AfterMethod
     31 	public void afterTest() {
     32 	}
     33 
     34 	@Test(groups = {"even"})
     35 	public void method2() {
     36 	}
     37 
     38 	@Test(groups = {"odd"})
     39 	public void method3() {
     40 	}
     41 
     42 	@Test(groups = {"odd"}, enabled = false)
     43 	public void oddDisableMethod() {
     44 	}
     45 
     46 	@Test(groups = {"broken"})
     47 	public void broken() {
     48 	}
     49 
     50 	@Test(groups = {"fail"})
     51 	@ExpectedExceptions( {NumberFormatException.class,	ArithmeticException.class})
     52 	public void throwExpectedException1ShouldPass() {
     53 		throw new NumberFormatException();
     54 	}
     55 
     56 	@Test(groups = {"fail"})
     57 	@ExpectedExceptions( {NumberFormatException.class,	ArithmeticException.class})
     58 	public void throwExpectedException2ShouldPass() {
     59 		throw new ArithmeticException();
     60 	}
     61 
     62 	@Test(groups = {"fail", "bug"})
     63 	public void throwExceptionShouldFail() {
     64 		throw new NumberFormatException();
     65 	}
     66 
     67 	@Test(groups = {"assert"})
     68 	public void verifyLastNameShouldFail() {
     69 	  Assert.assertEquals("Beust", "", "Expected name Beust, found blah");
     70 	}
     71 
     72 	private static void ppp(String s) {
     73 		System.out.println("[Test1] " + s);
     74 	}
     75 
     76 }
     77