Study Java

고정 헤더 영역

글 제목

메뉴 레이어

Study Java

메뉴 리스트

  • 홈
  • 태그
  • 방명록
  • 분류 전체보기 (137)
    • Java (52)
    • Junit4 (11)
    • Spring (9)
    • JSP (23)
    • Mybatis (4)
    • IntelliJ (1)
    • maven (1)
    • 토비의스프링 (21)
    • JQuery Plug in (6)
    • CSS (1)
    • 데이터베이스 (1)
      • MySQL 기초 (1)

검색 레이어

Study Java

검색 영역

컨텐츠 검색

Junit4

  • [ Junit4 ] allOf, anyOf

    2020.06.18 by kwanghyup

  • [Junit4] containsString, both, either

    2020.06.18 by kwanghyup

  • [Junit] assertThat, hasItems

    2020.06.18 by kwanghyup

  • [Junit4] assertTrue, assertFalse : 조건이 true 또는 false인지 여부

    2020.06.18 by kwanghyup

  • [ Junit4 ] assertNotSame, assertSame : 두 변수의 참조 값이 같은지 여부

    2020.06.17 by kwanghyup

  • [Junit4] assertNotNull, assertNull : 객체가 null 인지 여부

    2020.06.17 by kwanghyup

  • [ Junit4 ]assertArrayEquals : 두 배열이 같은지 여부

    2020.06.17 by kwanghyup

  • [Junit4] assertEquals : 두 객체의 값이 같은지 여부

    2020.06.17 by kwanghyup

[ Junit4 ] allOf, anyOf

import org.junit.Test; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.assertThat; public class SampleTest { @Test public void test_allOf() { String actual = "public static void test"; // allOf : 내부의 모든 매처들이 일치하는 경우 테스트 통과 assertThat(actual, allOf( containsString("ati"), startsWith("pub"), equalTo("public static void test") ) ); } // end @Test public void test_anyOf(){ ..

Junit4 2020. 6. 18. 08:42

[Junit4] containsString, both, either

import org.junit.Test; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.assertThat; public class SampleTest { @Test public void test_containsString(){ String actual = "terran"; assertThat(actual, containsString("rr")); } @Test public void test_both_either() { String actual = "albumen"; // both A and B assertThat(actual, both(containsString("a")) .and(containsString("b"))..

Junit4 2020. 6. 18. 01:53

[Junit] assertThat, hasItems

import org.junit.Test; import java.util.Arrays; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.MatcherAssert.assertThat; public class SampleTest { @Test public void testAssertThatHasItems() { assertThat( Arrays.asList("Java", "Kotlin", "Scala"), hasItems("Java", "Kotlin")); } }

Junit4 2020. 6. 18. 01:30

[Junit4] assertTrue, assertFalse : 조건이 true 또는 false인지 여부

package org.example; import org.junit.Test; import static org.junit.Assert.*; public class SampleTest { // assertTrue and assertFalse @Test public void test_assertTrue(){ assertTrue(5>4); } @Test public void test_assertFalse(){ assertFalse(5

Junit4 2020. 6. 18. 01:05

[ Junit4 ] assertNotSame, assertSame : 두 변수의 참조 값이 같은지 여부

public class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } } import org.junit.Test; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; public class SampleTest { @Test public void test_assertNotSame(){ // 두 변수가 다른 객체를 참조하는 경우 테스트에 성공한다. Person person1 = new Person("lee",36); Person per..

Junit4 2020. 6. 17. 23:59

[Junit4] assertNotNull, assertNull : 객체가 null 인지 여부

import org.junit.*; import java.util.Arrays; import java.util.List; import static org.junit.Assert.*; public class SampleTest { String test1; String[] test2; List test3; Person person; String test4; @Before public void setUp(){ test1 = "hello"; test2 = new String[]{"1", "2"}; test3 = Arrays.asList("가","나","다"); person = new Person("lee",12); } @Test public void test_assertNotNull(){ // 기본타입, 배열,..

Junit4 2020. 6. 17. 23:27

[ Junit4 ]assertArrayEquals : 두 배열이 같은지 여부

import org.junit.*; import static org.junit.Assert.assertArrayEquals; public class SampleTest { @Test public void test_assertArrayEquals1() { char[] expected = {'J','u','n','i','t'}; char[] actual = "Junit".toCharArray(); assertArrayEquals(expected,actual); // assertArrayEquals("실패 시 표시",expected,actual); } @Test public void test_assertArrayEquals2() { // 두 배열이 모두 null 인 경우 같은 배열로 간주 한다. int[] e..

Junit4 2020. 6. 17. 23:11

[Junit4] assertEquals : 두 객체의 값이 같은지 여부

import org.junit.*; import static org.junit.Assert.assertEquals; public class SampleTest { @Test public void whenAssertingEquality_thenEqual() { String expected = "Ramesh"; String actual = "Ramesh"; // 예상값과 실제 값이 같은지 확인 assertEquals(expected, actual); } } 테스트가 실패할 시 메세지를 표시할 수 있다. @Test public void whenAssertingEquality_thenEqual() { String actual = "java"; String expected = "java "; assertEqual..

Junit4 2020. 6. 17. 22:28

추가 정보

인기글

최신글

페이징

이전
1 2
다음
TISTORY
Study Java © Magazine Lab
페이스북 트위터 인스타그램 유투브 메일

티스토리툴바