Skip to content

Add the posibility to use @Before with bindMany #67

@michelefi

Description

@michelefi

bindMany and All annotation doesn't permit to setup up the binded instance with a before annotated method.
The following code demonstrate the use case:

import org.jukito.All;
import org.jukito.JukitoModule;
import org.jukito.JukitoRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

interface TestInterface {
  void foo();
}
class ImplOne implements TestInterface {
  public void foo() {
  }
}

class ImplTwo implements TestInterface {
  public void foo() {
  }
}

@RunWith(JukitoRunner.class)
public class BindManyTest {

  public static class Module extends JukitoModule {

    @Override
    protected void configureTest() {
      bindMany(TestInterface.class, ImplOne.class, ImplTwo.class);
    }
  }

  @Before
  public void setup(TestInterface test) {
    System.out.println(test.getClass().getSimpleName());
  }

  @Test
  public void testGetFlight(@All TestInterface test) {
    System.out.println(test.getClass().getSimpleName());
  }
}

When running the test I expect as output:

ImplOne
ImplOne
ImplTwo
ImplTwo

Instead the output is:

TestInterface$$EnhancerByMockitoWithCGLIB$$78a15e3b
ImplOne
TestInterface$$EnhancerByMockitoWithCGLIB$$78a15e3b
ImplTwo

It's possible to support the All annotation also in Before method or fix the behavior?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions