• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.dataprovider;
2 
3 import com.google.inject.AbstractModule;
4 import com.google.inject.name.Names;
5 
6 import org.testng.Assert;
7 import org.testng.annotations.Guice;
8 import org.testng.annotations.Test;
9 
10 @Guice(modules = StaticDataProviderSampleTest.InjectionProviderModule.class)
11 public class StaticDataProviderSampleTest {
12 
13   @Test(dataProvider = "static", dataProviderClass = StaticProvider.class)
verifyStatic(String s)14   public void verifyStatic(String s) {
15     Assert.assertEquals(s, "Cedric");
16   }
17 
18   @Test(dataProvider = "external", dataProviderClass = NonStaticProvider.class)
verifyExternal(String s)19   public void verifyExternal(String s) {
20     Assert.assertEquals(s, "Cedric");
21   }
22 
23   @Test(dataProvider = "injection", dataProviderClass = FieldInjectionProvider.class)
verifyFieldInjection(String s)24   public void verifyFieldInjection(String s) {
25     Assert.assertEquals(s, "Cedric");
26   }
27 
28   @Test(dataProvider = "injection", dataProviderClass = ConstructorInjectionProvider.class)
verifyConstructorInjection(String s)29   public void verifyConstructorInjection(String s) {
30     Assert.assertEquals(s, "Cedric");
31   }
32 
33   public static class InjectionProviderModule extends AbstractModule {
34 
35     @Override
configure()36     protected void configure() {
37       bind(String.class).annotatedWith(Names.named("test")).toInstance("Cedric");
38     }
39   }
40 }
41