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
tearDownClass1()19 	public static void tearDownClass1() {
20 	}
21 
22 	@AfterClass
tearDownClass2()23 	public void tearDownClass2() {
24 	}
25 
26 	@BeforeMethod
beforeTest()27 	public void beforeTest() {
28 	}
29 
30 	@AfterMethod
afterTest()31 	public void afterTest() {
32 	}
33 
34 	@Test(groups = {"even"})
method2()35 	public void method2() {
36 	}
37 
38 	@Test(groups = {"odd"})
method3()39 	public void method3() {
40 	}
41 
42 	@Test(groups = {"odd"}, enabled = false)
oddDisableMethod()43 	public void oddDisableMethod() {
44 	}
45 
46 	@Test(groups = {"broken"})
broken()47 	public void broken() {
48 	}
49 
50 	@Test(groups = {"fail"})
51 	@ExpectedExceptions( {NumberFormatException.class,	ArithmeticException.class})
throwExpectedException1ShouldPass()52 	public void throwExpectedException1ShouldPass() {
53 		throw new NumberFormatException();
54 	}
55 
56 	@Test(groups = {"fail"})
57 	@ExpectedExceptions( {NumberFormatException.class,	ArithmeticException.class})
throwExpectedException2ShouldPass()58 	public void throwExpectedException2ShouldPass() {
59 		throw new ArithmeticException();
60 	}
61 
62 	@Test(groups = {"fail", "bug"})
throwExceptionShouldFail()63 	public void throwExceptionShouldFail() {
64 		throw new NumberFormatException();
65 	}
66 
67 	@Test(groups = {"assert"})
verifyLastNameShouldFail()68 	public void verifyLastNameShouldFail() {
69 	  Assert.assertEquals("Beust", "", "Expected name Beust, found blah");
70 	}
71 
ppp(String s)72 	private static void ppp(String s) {
73 		System.out.println("[Test1] " + s);
74 	}
75 
76 }
77