pchudzik / springmock

alternative spring mocking infrastructure
https://blog.pchudzik.com/201707/springmock-v1/
MIT License
22 stars 4 forks source link

spy should be distinguished from mock if they are both of the same class #8

Closed pchudzik closed 7 years ago

pchudzik commented 7 years ago

If mock is of the same class as spy and both are injected into specification infrastructure doesn't distinguish them and injects mock in place of spy (or other way around).

Sample test case: ''' @AutowiredSpy MyService spy;

@AutowiredMock
MyService mock;

@Test
public void spy_should_be_distinguishable_from_mock_of_the_same_class() {
    assertNotSame(spy, mock);
}

@Test
public void should_distinguish_mock() {
    assertSame(aMock, mock);
}

@Test
public void should_distinguish_spy() {
    assertSame(aSpy, spy);
}

'''

Detailed test case: com.pchudzik.springmock.infrastructure.test.SpyAndMockOfTheSameClassShouldBeDistinguishable (ignored right now)

pchudzik commented 7 years ago

yet another test case com.pchudzik.springmock.infrastructure.test.distinguish.PartialMocksShouldBeDistinguishable

which is somehow related to this issue

pchudzik commented 7 years ago

when fixed take a look at com.pchudzik.springmock.infrastructure.test.duplicates.NamedDoublesShouldBeDistinguishable and replace SpyService1 SpyService2 with single class

pchudzik commented 7 years ago

will eventually merge to master https://travis-ci.org/pchudzik/springmock/builds/269899373