FitLibrary
FitLibrary는 fixture의 third-party set으로 시작했습니다. 하지만 이 기능이 하도 유용해서 지금은 standard test 타입의 하나로 간주되고 있습니다. 자바버전에서는 아직 별도의 라이브러리로 관리됩니다.
SetUpFixture
SetUpFixture는 아무것도 테스트하지 않고 싶을 때 ColumnFixture를 완벽하게 대신할 수 있는 fixture 입니다. 다른 fixture들을 위한 stage를 준비하기 위해서 사용하는 것이죠. 예를 들어 데이터메이스의 테이블에 row들을 insert하거나 이후의 테스트들에서 사용될 domain object들을 생성할 때 이 SetUpFixture를 사용하실 수 있습니다.
Table Format
첫번째 줄은 fixture 클래스 이름이 됩니다. 두번째줄은 객체의 프로퍼티 이름들 입니다. 이후의 모든 줄들은 프로퍼티값들을 가지게 됩니다. 이 SetUpFixture table 에는 output cell 이 없습니다. 모두 input에만 사용이 됩니다.
!|SetUpFixtureTest| |player|post code|balance| |John Smith|SW4 66Z|10.00| |Michael Jordan|NE1 8AT|12.00|
Fixture class
이 fixture 클래스는 fitlibrary.SetUpFexture를 extend 하고 single method를 정의합니다. 메소드 이름은 연결된 테이블에 있는 프로퍼티 이름들과 같아야 합니다. (두개의 분리된 단어를 표현하려면 CamelCase capitalisation을 사용하시면 됩니다.) 이 메소드는 테이블의 각 컬럼들에 대해 하나씩의 argument를 가지게 됩니다.
Java Source Code
package info.fitnesse.fixturegallery;
import info.fitnesse.fixturegallery.domain.Player;
import java.util.ArrayList;
import java.util.List;
import fitlibrary.SetUpFixture;
public class SetUpFixtureTest extends SetUpFixture{
public SetUpFixtureTest() {
Player.players.clear();
}
public void playerPostCodeBalance(String name, String postCode, double balance){
Player.addPlayer(name, postCode, balance) ;
}
}
.NET Source Code
namespace info.fitnesse.fixturegallery
{
public class SetUpFixtureTest : fitlibrary.SetUpFixture
{
public SetUpFixtureTest()
{
Player.players.Clear();
}
public void PlayerPostcodeBalance(string player, string postCode, decimal balance)
{
Player p = new Player();
p.Name = player;
p.PostCode = postCode;
p.Balance = balance;
Player.players.Add(p);
}
}
}
Python Source Code
from fitLib.SetUpFixture import SetUpFixture
from info.fitnesse.fixturegallery.domain.Player import Player
class SetUpFixtureTest(SetUpFixture):
_typeDict = {}
def __init__(self):
Player.players = []
# JAVA: void playerPostCodeBalance(String name, String postCode, double balance){
_typeDict["playerPostCodeBalance.types"] = [ None, "String", "String", "Float" ]
def playerPostCodeBalance(self, name, postCode, balance):
Player.addPlayer(name, postCode, balance)
Notes
메소드 이름은 길어 질 수도 있습니다. 이런 긴 메소드 이름을 타이핑하다보면 에러가 발생할 수가 있습니다. 매뉴얼로 타이핑하는 대신 테이블을 작성하고 test를 run 하세요. 그러면 처음에는 fail 하게 될 겁니다.
Usage
이 SetUpFixture는 domain object들을 신속하게 initialise 하고자 할 때 사용하실 수 있습니다. 데이터베이스 테이블을 준비하거나 서로 다른 argument들을 pass 해서 메소드를 여러번 실행시키고자 할 때 사용하기 좋습니다.
result나 error verification이 중요할 때 이 SetUpFixture를 사용하지는 마세요. 그럴때는 ColumnFixture를 사용하시거나 CalculateFixture를 사용하시는게 더 좋습니다.
'TDD Project' 카테고리의 다른 글
| CombinationFixture Tutorial - FitLibrary - (0) | 2013.08.22 |
|---|---|
| ArrayFixture Tutorial - FitLibrary - (0) | 2013.08.21 |
| SequenceFixture Tutorial - FitLibrary - (0) | 2013.08.21 |
| DoFixture Tutorial - FitLibrary - (0) | 2013.08.17 |
| CalculateFixture Tutorials - FitLibrary - (0) | 2013.08.17 |
| Import Fixture Tutorial & Summery (FitNesse) (1) | 2013.08.17 |
| TableFixture Tutorial (FitNesse) (0) | 2013.08.14 |
| RowFixture Tutorial (Fitnesse) (0) | 2013.08.14 |
| ActionFixture Tutorial (Fitnesse) (0) | 2013.08.14 |
| ColumnFixture Tutorial (Fitnesse) (0) | 2013.08.12 |
