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. [2012/01/13] Private Video Sharing Service 'Givit' by Creativity, Safety, and Life (511)
  2. [2011/09/15] 24 Usability Testing Tools by Creativity, Safety, and Life (1557)
  3. [2011/09/07] Online Free Documentary Website (Documentary Heaven) by Creativity, Safety, and Life (1973)
  4. [2011/07/26] 스프링에서 한글 깨지는 문제 by 어린꿀벌 (2155)
  5. [2011/05/30] Eclipse 인코딩 설정하기 by 운학귀신 (1382)
Tag :

Leave Comments

T-NAVI