ActionFixture
ActionFixture 는 기본적으로 반복적인 경우가 아니라 workflow-style test를 위한 겁니다. 다른 fixture들을 automate 하기 위해 UI metaphor 를 사용합니다.
Table Format
ActionFixture table의 첫번째 줄(row)은 fixture class를 initialise합니다. 이 경우에는 다른 custom subclass가 아니라 ActionFixture
그 자체가 되겠습니다. 다른 모든 row들은 command cell 로 시작됩니다. 그리고 이 후의 cell 들에는 command argument들이 이어서 들어옵니다. 어떤 row들은 두개를 어떤 줄들은 3개의 셀들을 가집니다.
두번째 줄은 주로 start command 로 사용됩니다. 하나의 argument를 필요로 하죠. 그리고 automate 하는 실제 fixture의 클래스 이름이 옵니다. 그 다음에 테스트를 하기 위해 다른 command들을 사용하실 수 있습니다.
- check — executes a method and verifies its value.
- press — executes a void method without testing anything.
- enter — executes a method and passes an argument to it.
여러분은 ActionFixture 를 UI form들을 populate 하고 method들과 연결된 버튼을 click 하기 위한 automation tool로 생각하셔도 됩니다.
!|ActionFixture| |start|ActionFixtureTest| |enter|firstPart|Hello| |enter|secondPart|World| |press|join| |check|together|Hello, World|
(이 이미지는 source code와 다른 화면 입니다.)
Fixture class
다른 Fixture와 ActionFixture 가 다른 점은 따로 ActionFixture 를 extend 하지 않아도 된다는 겁니다. ActionFixture 대신에 fit.Fixture class를 곧바로 extend 합니다.
Java Source Code
package info.fitnesse.fixturegallery;
public class ActionFixtureTest extends fit.Fixture{
private String first, second, both;
public void firstPart(String s){
first=s;
}
public void secondPart(String s){
second=s;
}
public void join(){
both=first+ ", "+second;
}
public String together(){
return both;
}
}
.NET Source Code
using System;
namespace info.fitnesse.fixturegallery
{
public class ActionFixtureTest: fit.Fixture
{
public String firstPart, secondPart, together;
public void join()
{
together=firstPart+ ", "+secondPart;
}
}
}
Python Source Code
from fit.Fixture import Fixture
class ActionFixtureTest(Fixture):
_typeDict = {}
def __init__(self):
Fixture.__init__(self)
self.__first = "" #< Private attributes (Python convention).
self.__second = ""
self.__both = ""
# JAVA: void firstPart(String s)
_typeDict["firstPart"] = "String"
def firstPart(self, s):
self.__first = s
# JAVA: void secondPart(String s)
_typeDict["secondPart"] = "String"
def secondPart(self, s):
self.__second = s
# JAVA: void join()
_typeDict["join"] = "Default" #< AUTO-DETECT: None = void
def join(self):
self.__both = "%s, %s" % (self.__first, self.__second)
# JAVA: String together()
_typeDict["together"] = "String"
def together(self):
return self.__both
Notes
In the Java version, ActionFixture only works on methods. in the .NET version, enter and check can get and set fields and properties as well.
자바 버전에서는 ActionFixture 가 오직 method에 대해서만 적용됩니다. .NET 버전에서는 enter 와 check 이 필드와 프로퍼티들을 get,set 할 수 있습니다.
Usage
여러분은 ActionFixture 를 UI-style verification들을 처리하기 위해 사용하실 수 있습니다.
일반적으로 ActionFixture 는 DoFixture (see DoFixture )에 의해 replace 됩니다. 요즘은 이 ActionFixture를 써야 되는 경우가 한정돼 있죠. DoFixture 도 workflow-style 테스트를 할 수 있도록 기능을 제공 합니다. 사실 훨씬 더 쉽게 사용할 수 있도록 해 줍니다. DoFixture 가 fixture와 FitNesse table 모두 더 적은 코딩을 할 수 있도록 해 주고요. DoFixture는 direct domain object wrapping 도 지원합니다.
'TDD Project' 카테고리의 다른 글
| CalculateFixture Tutorials - FitLibrary - (0) | 2013.08.17 |
|---|---|
| SetUpFixture tutorial -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 |
| ColumnFixture Tutorial (Fitnesse) (0) | 2013.08.12 |
| Spring Framework에서 jUnit 테스트 만들기 - Mockito 를 중심으로 - (0) | 2013.08.11 |
| Fitnesse 사용법 간단 정리 (0) | 2013.08.07 |
| Mockito로 테스트 하기 (0) | 2013.06.17 |
| jUnit 으로 Private Method 테스트 만들기 2 (0) | 2013.06.10 |
