/** * Tests for {@link HelloWorldController}. Modify the tests in order to support your use case as you build your project. */ @DisplayName("Tests for HelloWorldController") publicclassHelloWorldControllerTest{
privatefinal HelloWorldController controller = new HelloWorldController();
/** * Initializing variables before we run the tests. * Use @BeforeAll for initializing static variables at the start of the test class execution. * Use @BeforeEach for initializing variables before each test is run. */ @BeforeAll staticvoidsetup(){ // Use as needed. }
/** * De-initializing variables after we run the tests. * Use @AfterAll for de-initializing static variables at the end of the test class execution. * Use @AfterEach for de-initializing variables at the end of each test. */ @AfterAll staticvoidtearDown(){ // Use as needed. }
/** * Basic test to verify the result obtained when calling {@link HelloWorldController#helloWorldGet} successfully. */ @Test @DisplayName("Basic test for GET request") voidtestGetRequest(){ ResponseEntity responseEntity = controller.helloWorldGet(INPUT_NAME);
// Verify the response obtained matches the values we expect. JSONObject jsonObjectFromResponse = new JSONObject(responseEntity.getBody().toString()); assertEquals(EXPECTED_RESPONSE_VALUE, jsonObjectFromResponse.get("Output")); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); }
/** * Basic test to verify the result obtained when calling {@link HelloWorldController#helloWorldPost} successfully. */ @Test @DisplayName("Basic test for POST request") voidtestPostRequest(){ ResponseEntity responseEntity = controller.helloWorldPost(INPUT_NAME);
// Verify the response obtained matches the values we expect. JSONObject jsonObjectFromResponse = new JSONObject(responseEntity.getBody().toString()); assertEquals(EXPECTED_RESPONSE_VALUE, jsonObjectFromResponse.get("Output")); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); } }
만약에 테스트코드가 존재하지 않는다면 CI 도입이 필요하지 않음
코드를 작성 후 테스틐 코드 없이 배포를 자동으로 맡겨버리게 된다면 사이드이펙트 체크 불가
테스트 코드가 없다면 수동배포와 별차이가 없음
STEP 12
글을 작성하다보니 빌드 및 배포 완료
STEP 13
오른쪽 소스, 빌드, 디플로이 시간
커밋이력 또한 볼수 있음! jira컨플런스랑 연동도 가능합니다.
결론
많은 셋팅 없이 ci구축이 가능하며, aws에서 제공해주는 다양한 서비스들을 한번에 올라옴