-
-
Save making/30684220dd72d91f483a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeService { | |
//これをいれかえたい。 | |
@Autowired | |
SomeRepository someRepository; | |
// | |
// | |
// | |
} | |
@Repository | |
public class SomeRepositoryImpl implements SomeRepository { | |
//いろいろな本番処理 | |
} | |
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration | |
public class SomeServiceTest { | |
@Autowired | |
SomeService someService; | |
@Autowired | |
SomeRepository someRepository; | |
@Test | |
public void testHoge() throws Exception { | |
System.out.println(someRepository); // こいつはMock | |
System.out.println(someService); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | |
<bean class="org.mockito.Mockito" factory-method="mock"> | |
<constructor-arg value="com.example.repository.SomeRepository" /> | |
</bean> | |
<bean class="com.example.service.SomeService"/> | |
</beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment