1
私はユニットテストをIntellij IdeaのSpring Bootアプリケーションに書き出し始めています。Appが起動するたびにユニットテストが実行されない
私は、このテストクラスがあります。
@RunWith(SpringJUnit4ClassRunner.class)
@WebIntegrationTest(randomPort=true)
@SpringApplicationConfiguration(Application.class)
public class UserTest {
@Value("${local.server.port}")
private int port;
private TestRestTemplate restTemplate = new TestRestTemplate();
@Test
public void login() {
User myUser = new User();
myUser.setUsername("myName");
myUser.setPassword("myPass");
ResponseEntity<String> r = this.restTemplate.getForEntity("http://localhost:"+port+"https://stackoverflow.com/users/login?username="+myUser.getUsername()+"&password="+myUser.getPassword(), String.class);
assertThat(r.getBody(), containsString("myName"));
}
@Test
public void getUsername() throws Exception {
User user = new User();
assertNotEquals("myName", user.getUsername());
}
}
私は実行 - >実行を通してそれを実行したときにこれが「UserTest」正常に動作しますが、どのように私は起動時に自動的に実行することで入手できますかアプリケーションを起動し、Springブート出力ウィンドウでテスト結果を出力するようにしますか?
私はGradleを使用していますか? – Meital
Gradleのデフォルト設定に基づいて新しい設定を作成します。次に、実行するGradleタスクをフォームフィールドに配置します。 –