interface EnvironmentChecker
{
Environment getEnvironment(); // ProductionEnvironment, DevelopmentEnvironment, etc.
}
String concatStrings(String... strings)
{
if (DevelopmentEnvironment == getEnvironment())
{
// Try new high-performance string concat tool.
return coolStringConcatTool.concat(strings);
}
else
{
// Production relies on tried-and-true for now.
return string1 + string2 + string3... etc;
}
}
// configure test
public static class Module extends JukitoModule
{
@Override
protected void configureTest()
{
bindMany(Environment.class, AlwaysPRODUCTION.class, AlwaysDEVELOPMENT.class);
}
}
@Before
void before(EnvironmentChecker mockChecker, @All Environment env)
{
when(mockChecker.getEnvironment()).thenReturn(evn);
}
@Test
void runThisTestMultipleTimes(AnyParams any) {}
// configure test
public
static class Module
extends JukitoModule
{
@Override
protected void configureTest()
{
bindMany(Environment.class,
AlwaysPRODUCTION.class, AlwaysDEVELOPMENT.class);
}
}
@Before
void before(EnvironmentChecker mockChecker,
Environment env)
{
when(mockChecker.getEnvironment()).thenReturn(evn);
}
@Test
void runThisTestMultipleTimes(@All Environment env,
AnyParams
any) {}
--
You received this message because you are subscribed to the Google Groups "Jukito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jukito+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public interface TestInterface {
void foo();
}
public class ImplOne implements TestInterface {
@Override
public void foo() {
}
}
public class ImplTwo implements TestInterface {
@Override
public void foo() {
}
}
@RunWith(JukitoRunner.class)
public class JukitoTest {
public static class Module extends JukitoModule {
@Override
protected void configureTest() {
bindMany(TestInterface.class, ImplOne.class, ImplTwo.class);
}
}
@Before
public void setup(TestInterface test) {
test.foo();
}
@Test
public void testGetFlight(TestInterface test) {
test.foo();
}
}
@RunWith(JukitoRunner.class)
public class JukitoTest {
public static class Module extends JukitoModule {
@Override
protected void configureTest() {
bindMany(TestInterface.class, ImplOne.class, ImplTwo.class);
}
}
@Before
public void setup(TestInterface test) {
test.foo();
}
@Test
public void testGetFlight(@All TestInterface test) {
test.foo();
}
}
The @All only works for parameters in @Test methods.
But you can add the same parameter (without @All) to the @Before method. This way the same instance is injected into both methods.
You received this message because you are subscribed to a topic in the Google Groups "Jukito" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jukito/gFhJBynvJeA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jukito+un...@googlegroups.com.