1 package test.inject; 2 3 import org.testng.Assert; 4 import org.testng.annotations.DataProvider; 5 import org.testng.annotations.NoInjection; 6 import org.testng.annotations.Test; 7 8 import java.lang.reflect.Method; 9 10 /** 11 * Test the @NoInjection annotation. 12 * 13 * @author cbeust 14 */ 15 public class NoInjectionTest { 16 17 @DataProvider(name = "provider") provide()18 public Object[][] provide() throws Exception { 19 return new Object[][] { { CC.class.getMethod("f") } }; 20 } 21 22 @Test(dataProvider = "provider") withoutInjection(@oInjection Method m)23 public void withoutInjection(@NoInjection Method m) { 24 Assert.assertEquals(m.getName(), "f"); 25 } 26 27 @Test(dataProvider = "provider") withInjection(Method m)28 public void withInjection(Method m) { 29 Assert.assertEquals(m.getName(), "withInjection"); 30 } 31 } 32 33 class CC { 34 f()35 public void f() { 36 } 37 } 38