私の春のプロジェクトをテストしたいです。私はテストクラスで偽のクライアントを模倣する必要がありますが、通常の実装は模擬実装の代わりにautowiredになります。ここに私のコードのトップです。 PLZヘルプ。 @ActiveProfiles("test")
とfeignクライアントの模擬実装はオートワイヤではありません
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebIntegrationTest({"server.port:0", "spring.profiles.active:test"})
public class RegistrationControllerTest {
@Autowired
WebApplicationContext wac;
@Autowired
TokenRepository tokenRepository;
private static MockMvc mockMvc;
private static ObjectMapper mapper = new ObjectMapper();
// token and sender id are required for communicating with google
private static String senderId = "553921561995";
private static String token =
"ecdNq6_jeTM:APA91bEgWsJeIS5cXFwWrj_83EKeLWRFf1" +
"- lNQGXA1uWdzrfHLpd7fAY7ur6Pplc4TQuKmEDiSUhUBhDdQLwG2a_fxdgoGbDrKNLjPm2E7JOMJFjk65jtFGHrjJ39NkgABtfn6MDVUCQ";
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).apply(springSecurity()).build();
tokenRepository.deleteAll();
}