Skip to content

[TDD] Video tutorial: Test Driven Development in practice 개발이야기

eclipse, junit를 통해 계산기를 tdd 개발하는 과정을 보여주는 스크린케스트입니다.

tdd의 기초를 다질 때 보면 좋을것 같습니다.


원문 : http://agilesoftwaredevelopment.com/videos/test-driven-development-basic-tutorial



https://java-code-practice-with-tdd.googlecode.com/svn/trunk/java-code-practice-with-tdd/src/test/java/com/ncrash/calculator/CalculatorTest.java
 package com.ncrash.calculator;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * 
 * @author daekwon.kang
 * @since 2010. 7. 7.
 * @see 
 */
public class CalculatorTest {

    private Calculator calc;

    @Before
    public void before() {
        calc = new Calculatorimpl();
    }
    
    @Test
    public void testAdd() throws Exception {
        assertNotNull("calc is null", calc);
        assertEquals(101, calc.add(23, 78));
        
        try {
            calc.add(Integer.MAX_VALUE, 100);
            fail(OverflowException.class.getName() + " is excepted");
        } catch(OverflowException e) {
            
        }
        
        try {
            calc.add(Integer.MIN_VALUE, -1);
            fail(UnderflowException.class.getName() + " is excepted");
        } catch(UnderflowException e) {
            
        }
    }
    
    @Test
    public void testSub() throws Exception {
        assertNotNull("calc is null", calc);
        assertEquals(10, calc.sub(20, 10));
        
        try {
            calc.sub(Integer.MIN_VALUE, 100);
            fail(UnderflowException.class.getName() + " is excepted");
        } catch(UnderflowException e) {
            
        }
        
        try {
            calc.sub(Integer.MAX_VALUE, -10);
            fail(OverflowException.class.getName() + " is excepted");
        } catch(OverflowException e) {
            
        }
    }
}

Share
이 글과 관련된 글
  1. [2010/08/21] (번역) 오라클의 안드로이드 소송: 악의 판도라 상자 by 개고기 (338)
  2. [2010/08/02] [SCJP] SCJP 자격증에 대해 알아보자~! by 세미해커 (334)
  3. [2010/07/17] selenium Browser automation framework by 고집불통 때쟁이 (325)
  4. [2010/07/15] struts2, urlrewrite 설정 by 파란하늘 (274)
  5. [2010/07/08] xstream int, null값의 입력 by 파란하늘 (304)
Tag :

Leave Comments

T-NAVI