I want to use WebTestClient in my tests. works like this:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebTestClient
public class ControllerTest {
@Autowired
private WebTestClient webTestClient;
@Test
public void webtestClient () {
assertNotNull(webTestClient);
}
}
But now I want to inject WebTestClient into a helper class:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebTestClient
public class ControllerTest {
@Autowired
private Helper helper;
@Test
public void webtestClient () {
helper.check();
}
}
@Component
public class Helper {
@Autowired
private WebTestClient webTestClient;
public void check() {
assertNotNull(webTestClient);
}
}
Works, too. But Intellij is showing an error:
Could not autowire. No beans of 'WebTestClient' type found. more... (Strg+F1)
How can I fix this?
Aucun commentaire:
Enregistrer un commentaire