반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

CombinationFixture Tutorial - FitLibrary -

2013. 8. 22. 12:53 | Posted by 솔웅


반응형

CombinationFixture

CombinationFixture 는 values들에 대해 pair로 operation 하는 경우 사용됩니다. value들은 row와 컬럼에 명시되고 그 operation은 다른 모든 관계된 values들을 사용해 perform 됩니다.



Table Format

테이블의 첫번째 줄은 fixture class 이름이다. 두번째 줄은 empty cell 이고 그 다음에 해당 operation에 대한 두번째 파라미터로 쓰일 값이 오게 됩니다. 그 이후의 줄들에는 해당 operation에 대한 첫번째 파라미터로 사용될 값이 첫번째 cell 에 들어옵니다. 그 다음에 해당 operation의 expected value 가 옵니다.


!|CombinationFixtureTest|
|  |1 |2|3|
|6 |6 |3|2|
|12|12|6|4|




Fixture class

이 fixture class는 fitlibrary.CombinationFixture를 extend 합니다. 이 fixture에서는 두개의 값들 (row와 column) 그리고 return 값을 가지는 combine method를 정의해야 합니다.



Java Source Code


package info.fitnesse.fixturegallery;

import fitlibrary.CombinationFixture;

public class CombinationFixtureTest extends CombinationFixture{
    public int combine(int theFirst, int theSecond) {
        return theFirst / theSecond;
    }
}



.NET Source Code


using fitlibrary;

namespace info.fitnesse.fixturegallery {
    public class CombinationFixtureTest: CombinationFixture {
        public int combine(int theFirst, int theSecond) {
            return theFirst / theSecond;
        }
    }
}



Python Source Code


# PYTHON: info.fitnesse.fixturegallery.CombinationFixtureTest
from fitLib.CombinationFixture import CombinationFixture

class CombinationFixtureTest(CombinationFixture):
    _typeDict = {}

    # PY3K: combine(theFirst : int, theSecond : int) : int
    _typeDict["combine.types"] = [ "Int", "Int", "Int" ]
    def combine(self, theFirst, theSecond):
        return theFirst / theSecond



Usage

CombinationFixture는 정확히 두개의 argument를 가지고 계산하는 경우 사용될 수 있습니다.

반응형

ArrayFixture Tutorial - FitLibrary -

2013. 8. 21. 23:28 | Posted by 솔웅


반응형

ArrayFixture




ArrayFixtureRowFixture를 대신하기 위해 만들어 졌습니다. 다음 두가지 부분만 제외하고는 다른 fixture type과 유사합니다.

  1. Element order is important for ArrayFixture .
  2. ArrayFixture can work with generic collections as well as with arrays.

# section Table Format





Table Format



테이블의 첫번째 줄은 fixture class 이름이빈다. 두번째 줄은 collection elements 들의 structure 입니다. (필드, 프로퍼티, 메소드 이름들)


!include -seamless SetUpFixture

!|ArrayFixtureTest|
|name|post code|credit limit|
|John Smith|SW4 66Z|10|
|Michael Jordan|NE1 8AT|12|



Fixture class


이 fixture를 사용하려면 fitlibrary.ArrayFixture를 extend 해야 합니다. query method 대신 ArrayFixture는 internal property를 사용합니다. 자바버전에서는 이것을 actualCollection 이라고 합니다. 테이블의 값과 비교될 실제 result에 대한 fixture의 constructor(생성자)에 이것을 초기화(initialise) 합니다. .NET 버전에서는 base class constructor로 collection을 pass 해야 합니다.



Java Source Code



package info.fitnesse.fixturegallery;
import info.fitnesse.fixturegallery.domain.Player;
import fitlibrary.ArrayFixture;

public class ArrayFixtureTest extends ArrayFixture{
    public ArrayFixtureTest() {
        setActualCollection(Player.players);
    }
}




.NET Source Code



using System;
using System.Collections.Generic;
using System.Text;

namespace info.fitnesse.fixturegallery
{
    public class ArrayFixtureTest: fitlibrary.ArrayFixture
    {
        public ArrayFixtureTest():base(Player.players)
        {
        }
    }
}




Python Source Code



from fitLib.ArrayFixture import ArrayFixture
from info.fitnesse.fixturegallery.domain.Player import Player

class ArrayFixtureTest(ArrayFixture):
    def __init__(self):
        ArrayFixture.__init__(self)
        self.paramCollection = Player.players
        self.setActualCollection()

    def getTargetClass(self):
        return Player   #< TYPE-HINT: For ValueObject class.



Notes



자바 버전에서는 ArrayFixture로 JavaBean 프로퍼티에 대해서도 기능을 제공합니다. (만약에 getCreditLimit 같은 getter가 있다면 컬럼 이름을 credit limit 으로 명명할 수 있습니다.)

.NET 버전에서는 프로퍼티, 필드, 메소드들은 다 동일하게 취급됩니다. 어떤 것이든 fixture table에서 사용하실 수 있습니다.

FitLibrary에는 SetFixture 라는 것도 있는데요. 이것은 element 순서 같은 것은 무시합니다. SubSetFixture는 실제 result의 additional element들이 무시되구요. 이 두개의 fixture들은 이 ArrayFixture와 table format 이라던가 fixture class structure 들이 아주 비슷합니다.



Usage


element의 순서가 중요하거나 array안에 object list의 conversion 하기를 원하지 않으시면 RowFixture 대신 이 ArrayFixture를 사용하실 수 있습니다.

DoFixture는 반환되는 리스트나 배열을 가진 메소드를 자동으로 ArrayFixtuer로 wrap 할 겁니다. 즉 DoFixture를 사용하시면서 implicitly(내부적으로) 이 ArrayFixture를 사용하실 수 있습니다. 그러면 RowFixture class를 추가적으로 작성하지 않고도 객체의 리스트를 DoFixture만 가지고 테스트할 수 있습니다.  Flow Mode 에서 그 예를 보실 수 있습니다. DoFixture에서는 object들의 set를 return 하는 메소드도 자동으로 SetFixture로 wrap 됩니다.

자바에서는 business domain object들의 리스트에 대해서는 ArrayFixture를 사용하는게 더 좋습니다. ArrayFixture가 JavaBean들의 getter들에 대해 제대로 작동할 것이기 때문이죠.

반응형

SequenceFixture Tutorial - FitLibrary -

2013. 8. 21. 23:19 | Posted by 솔웅


반응형

SequenceFixture



SequenceFixture는 DoFixture와 아주 유사합니다. 거의 기능이 같죠. 다른 점이 있다면 메소드에 대한 naming convention 입니다. 메소드 이름으로 홀수번째 cell 을 이용하는거 대신에 SequenceFixture는 메소드 이름으로 각 줄의 첫번째 cell 을 채택합니다. 그리고 다른 cell 들은 arguments가 되는거죠. (row functionality를 modify 해야 할 keyword가 없을 경우에요.) DoFixture에서 사용하는 모든 keyword들도 마찬가지로 SequenceFixture에서도 지원됩니다. flow mode(see Flow Mode )와 domain object wrapping(see System under test) 도 마찬가지구요.





Table Format

table format은 method naming 부분만 빼면은 DoFixture와 같습니다. (see DoFixture)



!|SequenceFixtureTest|
|fill|10|x|
|check|char at|4|x|
|set list|A,B,C,D|
|check|char at|2|C|



Fixture class

이 fixture class는 fitlibrary.SequenceFixture를 extend 해서 사용합니다. 모든 verification들과 action들에 대해 public method를 선언합니다. 이 때 첫번째 cell이 method 이름으로 사용됩니다. 그리고 다른 cell 들은 argument들이 됩니다.



Java Source Code



package info.fitnesse.fixturegallery;
import java.util.Arrays;
import fitlibrary.SequenceFixture;

public class SequenceFixtureTest extends SequenceFixture{
    public String letters;
    public void fill(int count,char c){
        char[] arr=new char[count];
        Arrays.fill(arr,c);
        letters=new String(arr);
    }
    public void setList(char[] array){
        letters=new String(array);
    }
    public char charAt(int position){
        return letters.charAt(position);
    }
}



.NET Source Code


using System;

namespace info.fitnesse.fixturegallery
{
    public class SequenceFixtureTest : fitlibrary.SequenceFixture
    {
        private String contents;
        public void Fill(int howmany, String what)
        {
            contents = "";
            for (int i = 0; i < howmany; i++)
            {
                contents = contents + what;
            }
        }
        public void SetList(String[] strings)
        {
            contents = "";
            foreach (String s in strings)
            {
                contents = contents + s;
            }
        }
        public char CharAt(int index)
        {
            return contents[index];
        }
    }
}




Python Source Code


from fitLib.SequenceFixture import SequenceFixture
from info.fitnesse.fixturegallery.typeadapter import buildListTypeAdapterFor

class SequenceFixtureTest(SequenceFixture):
    _typeDict = {}

    def __init__(self):
        self.letters = ""

    _typeDict["fill.types"] = [ None, "Integer", "Char" ]
    def fill(self, count, c):
        self.letters = c * count    #< FILL: Repeact char count times.

    # JAVA: public void setList(char[] array){
    ARRAY_OF_CHAR_TYPE_ADAPTER = buildListTypeAdapterFor("Char")
    _typeDict["setList.types"] = [ None, ARRAY_OF_CHAR_TYPE_ADAPTER ]
    def setList(self, array):
        self.letters = "".join(array)   #< Concatenate array of chars to string.

    _typeDict["charAt.types"] = [ "Char", "Integer" ]
    def charAt(self, position):
        return self.letters[position]


Usage

SequenceFixtureDoFixture 가 가지고 있는 모든 flexibility와 기능을 모두 가지고 있습니다. 오직 method naming만 다릅니다. 이 fixture는 좀 더 technical 한 workflow test에 유용합니다.


반응형

DoFixture Tutorial - FitLibrary -

2013. 8. 17. 00:36 | Posted by 솔웅


반응형

DoFixture



DoFixture는 story-like test에 사용됩니다. ActionFixture 대신에 이 Fixture를 사용하실 수도 있습니다. 또한 ActionFixture에는 없는 다양한 기능들이 제공됩니다. flow-mode coordination이나 wrapping domain object 같은 것들이 그 예입니다.




Table Format

첫번째 줄은 fixture class 이름입니다. 그 이후의 모든 줄들은 verification을 실행하거나 fixture class의 메소드를 실행시킴으로서 어떤 일을 진행하도록 합니다. 메소드 이름은 그 줄의 홀수번째 cell들을 join 해서 만들어 집니다. argument 값들은 짝수번째 cell 들에서 가져오게 됩니다.

마약 메소드가 boolean 값을 반환한다면 그 줄은 테스트해야할 줄로 간주되고 FALSE를 반환하면 test fail로 간주 됩니다. 메소드가 void 거나 boolean 값 이외의 값을 반환하면 예외가 발생하지 않으면 그 메소드를 그대로 실행하게 됩니다.

!|DoFixtureTest|
|fill|10|times with|x|
|char at|4|is|x|
|set list|A,B,C,D|
|char at|2|is|C|




Fixture class

이 fixture를 사용하려면 fitlibrary.DoFixture를 extend 합니다. 모든 verification과 action들에 대해 public method를 정의합니다. 메소드 이름은 홀수번째에서 argument들은 짝수번째에서 가져 옵니다. 곧바로 메소드 이름을 타입할 필요는 없습니다. 테이블을 먼저 작성하고 그 다음에 테스트를 돌리세요. 처음에는 fail 하게 될 겁니다. 여기서 메소드 이름을 카피하시면 됩니다.

Java Source Code

package info.fitnesse.fixturegallery;
import java.util.Arrays;
import fitlibrary.DoFixture;

public class DoFixtureTest extends DoFixture {
	public String letters;
	public void fillTimesWith(int count,char c){
		char[] arr=new char[count];
		Arrays.fill(arr,c);
		letters=new String(arr);
	}
	public boolean charAtIs(int position, char c){
		return letters.charAt(position)==c;
	}
	public void setList(char[] array){
		letters=new String(array);
	}
	public char charAt(int position){
		return letters.charAt(position);
	}
}

.NET Source Code

using System;
using System.Collections.Generic;
using System.Text;

namespace info.fitnesse.fixturegallery
{
    public class DoFixtureTest : fitlibrary.DoFixture
    {
        private String contents;
        public void FillTimesWith(int howmany, String what)
        {
            contents = "";
            for (int i = 0; i < howmany; i++)
            {
                contents = contents + what;
            }
        }
        public bool CharAtIs(int index, char c)
        {
            return contents[index]==c;
        }
        public void SetList(String[] strings)
        {
            contents = "";
            foreach (String s in strings)
            {
                contents = contents + s;
            }
        }
        //
        public char CharAt(int index)
        {
            return contents[index];
        }
    }
}

Python Source Code

# NOTES:
#   This Fixture is not sensible in Python.
#   Python does not worry about character arrays, strings are used instead.
#   Therefore, a TypeAdapter for char is not supported by PyFIT.
#   I supplied one in this package

from fitLib.DoFixture import DoFixture
from info.fitnesse.fixturegallery.typeadapter import buildListTypeAdapterFor

class DoFixtureTest(DoFixture):
    _typeDict = {
        "letters": "String"
    }

    def __init__(self):
        DoFixture.__init__(self)
        self.letters = ""

    # JAVA: void fillTimesWith(int count,char c){
    _typeDict["fillTimesWith.types"] = [None, "Integer", "Char" ]
    def fillTimesWith(self, count, c):
        self.letters = c * count    #< FILL: Repeat char ``count`` times.

    # JAVA: boolean charAtIs(int position, char c){
    _typeDict["charAtIs.types"] = ["Boolean", "Integer", "Char" ]
    def charAtIs(self, position, c):
        return self.letters[position] == c

    # JAVA: void setList(char[] array){
    ARRAY_OF_CHAR_TYPE_ADAPTER = buildListTypeAdapterFor("Char")
    _typeDict["setList.types"] = [ None, ARRAY_OF_CHAR_TYPE_ADAPTER ]
    def setList(self, array):
        self.letters = "".join(array)

    # JAVA: char charAt(int position){
    _typeDict["charAt.types"] = [ "Char", "Integer" ]
    def charAt(self, position):
        return self.letters[position]




Notes

DoFixture는 메소드 이름을 위해 prefix 될 수 있는 여러 키워드들을 제공합니다. 키워드가 사용되면 홀수번째 셀들이 메소드 이름으로 사용되게 됩니다. 짝수번째 셀들은 argument 값들이구요. 아래 일반적으로 사용되는 키워드들을 소개합니다.

  • reject will invert the logic of a test, returning TRUE will make the test fail if the row is prefixed with reject .
  • show will print out the value of a calculation in the test results (similar to an empty cell in ColumnFixture ).
  • check allows you to verify results of non-boolean calculations. Prefix the row with check and put the expected value of the calculation on the end of the row, in a new cell.



자바 버전에서는 check show 가 JavaBean 프로퍼티들과 곧바로 매핑 됩니다. 그러니까 get prifix를 사용하지 않으셔도 됩니다. 이런 키워드들은 public fields들로 사용될 수 없습니다. .NET 버전에서는 그것들을 field, 프로퍼티 그리고 메소드에 사용할 수 있습니다. 또한 .NET에서는 프로퍼티 값을 세팅하기 위해 set이라는 키워드를 사용하실 수도 있습니다.

!|DoFixtureTest|
|fill|10|times with|x|
|check|char at|4|x|
|set list|A,B,C,D|
|show|char at|2|



Usage

DoFixture는 workflow test나 어떤 특정한 반복 구조가 아닌 그런 테스트에 사용하실 수 있습니다. DoFixture는 다른 fixture들과 같이 coordinating 하는에 아주 유용합니다.

반응형

CalculateFixture Tutorials - FitLibrary -

2013. 8. 17. 00:27 | Posted by 솔웅


반응형

CalculateFixture



CalculateFixture는 여러 input arguments에 대한 한개 이상의 계산 결과를 verify 할 때 사용합니다. ColumnFixture와 같은 일을 합니다. 테이블 포맷은 다르지만요. 이 CalculateFixture는 ColumnFixture 보다 코딩량을 줄여주는 효과가 있습니다.






Table Format

첫번째 줄은 fixture class 이름 입니다. 그 다음 두번째 줄에는 input parameter들의 이름을 넣습니다. 그 다음엔 빈 cell 이 오고 그 빈 셀 다음에 calculation 이름 (output value)이 옵니다. 이후 모든 줄들은 input parameter와 예상되는 outcomes들이 옵니다. 빈 셀은 이 줄들에서도 input과 output을 구분해 주는 역할을 합니다.

!|CalculateFixtureTest|
|firstPart|secondPart||together|
|Hello|World||Hello, World|
|Houston|We Have a Problem||Houston, We Have a Problem|




Fixture Class

이 Fixture는 fitlibrary.CalculateFixture를 extend 합니다. 각 calculation 컬럼에 대해 하나이 메소드를 정의합니다. 이 메소드 이름은 모든 파라미터 이름들로 연결된 calculation 이름과 같아야 합니다. (아래 경우에는 togetherFirstPartSecondPart이 됨) 별도의 단어를 구분하기 위해 CamelCase nameing을 사용하실 수 있습니다.

Java Source Code

package info.fitnesse.fixturegallery;

import fitlibrary.CalculateFixture;

public class CalculateFixtureTest extends CalculateFixture{
	public String togetherFirstPartSecondPart(String firstPart,String secondPart){
		return firstPart+ ", "+secondPart;
	}
}

.NET Source Code

using fitlibrary;
using System;

namespace info.fitnesse.fixturegallery
{
	public class CalculateFixtureTest: CalculateFixture
	{
		public String TogetherFirstPartSecondPart(String firstPart,String secondPart)
		{
			return firstPart+ ", "+secondPart;
		}
	}
}

Python Source Code

from fitLib.CalculateFixture import CalculateFixture

class CalculateFixtureTest(CalculateFixture):
    _typeDict = {}

    # JAVA: String togetherFirstPartSecondPart(String firstPart,String secondPart){
    _typeDict["togetherFirstPartSecondPart.types"] = ["String", "String", "String"]
    def togetherFirstPartSecondPart(self, firstPart, secondPart):
        return "%s, %s" % (firstPart, secondPart)




Notes

이 메소드 이름들은 길어질 수 있습니다. 타이핑을 하다보면 에러를 발생시킬수 있습니다. 테이블을 작성하고 test를 실행시키세요. 처음에는 fail 할 겁니다.

Usage 같은 메소드나 같은 메소드 set들을 여러 input들을 가지고 실행하고 그 결과값을 확인하고  싶을 때 이 CalculateFixture를 사용합니다. 단지 메소드 실행만 필요하고 그 결과값은 별로 중요하지 않다면 혹은 method가 return 값이 없는 void 라면 SetUpFixture를 사용하시는게 더 좋을 겁니다. 프로퍼티들을 초기화 한 다음에 domain object에 대해 메소드를 실행하기 원한다면 ColumnFixture 가 더 유용할 겁니다. ColumnFIxture는 또한 calculation의 result를 테이블에서 확인하도록 하는 기능도 제공합니다. CalculateFixture는 빈 셀을 blank string으로 취급합니다. 그리고 이것을 result와 비교합니다. 그러니까 output cell 을 empty로 놓게 되면 columnFixture는 그 결과 값을 빈 셀에 출력하지만 CalculateFixture는 fail을 출력하게 될 겁니다.

반응형

SetUpFixture tutorial -FitLibrary-

2013. 8. 17. 00:18 | Posted by 솔웅


반응형

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를 사용하시는게 더 좋습니다.

반응형

Import Fixture Tutorial & Summery (FitNesse)

2013. 8. 17. 00:10 | Posted by 솔웅


반응형

Import

Import fixture는 FitNesse에게 fixture class들에 대해 어디를 봐야될지 얘기해야 할 때 사용될 수 있다. namespace나 package 를 import 하고 나면 여러분은 더 이상 해당 fixture 클래스의 전체 이름을 다 쓰지 않아도 됩니다. 그러면 table을 좀 더 가독성 있도록 만들 수 있게 되겠죠.



Table Form

테이블의 첫번째 줄은 import 가 되어야 합니다. 그 다음 줄들은 import 할 namespace와 package들의 리스트들입니다. 한 셀당 한 row 입니다.

|Import|
|info.fitnesse.fixturegallery|




Notes

.NET 버전은 대소분자 구분을 하지 않습니다. 그러니까 첫번째 줄은 import를 쓰던 Import 를 사용하던 상관 없습니다. 자바버전은 대소분자 구분을 합니다. 그러니 대소분자 구분을 확실히 하셔서 사용하셔야 합니다.
flow mode에서는 Import 테이블이 flow calss name을 initial 한 이후에 와야 된다는 것을 잊지 마세요. 그렇지 않으면 folw mode가 제대로 작동하지 않을 겁니다. (Flow Mode links)



Usage

test page를 좀 더 가독성 있게 만들기 위해서 이 Import fixture를 사용합니다. test suite의 SetUp 페이지에 이 테이블을 넣으실 수 있습니다.



SummeryFixture

SummaryFixture는 페이지의 extra 데이터를 표시하기 위해 사용합니다. fit.SummaryFixture table을 페이지 아래에 추가히세요. 그러면 results 에 3줄의 테이블이 추가 될 겁니다. 그리고 여기에 페이지의 standard counts가 주어질 겁니다. (right,wrong, ignore, exceptions) 또한 date와 fixture가 실행된 시간도 표시됩니다. 이 기능은 꼭 필요한 것은 아닙니다. 하지만 build report가 필요할 때 사용하실 수 있겠죠. 개별 페이지의 실행시간 같은 것을 뽑을 때 말이죠.

==> 여기까지는 Fixture의 Basic 입니다. 이 외에 FitLibrary Fixture의 Fixture 들이 있는데 여기에 대해서는 다음 글에서 계속 이어가겠습니다.


참고로 아래 Basic Fixture에 종류와 원본 링크를 넣겠습니다.

원문에 관심 있으신 분은 링크를 따라 가시면 보실 수 있습니다.





Basic Fixtures


ColumnFixture
ActionFixture
RowFixture
TableFixture
Import
SummaryFixture

반응형


반응형

오늘은 어떻게 하다 보니까 아침 6시 반에 출근하게 됐습니다.


여유 있는 시간에 아래와 같은 생각을 해 봤습니다.


===============================


오늘은 박정희에 대한 제 생각을 정리해 보고 싶습니다.

누가 저에게 박정희는 어떤 사람이냐고 물어보면 저는 박정희는 나쁜 놈 입니다라고 말 할 겁니다.

그러면 반대쪽에서는 이런 저런 이유를 대면서 박정희는 아주 훌륭한 사람이라고 설명을 하겠죠.

아마 저는 그 얘기를 가만히 듣고 나서 그 말도 맞다 박정희는 나쁜 놈은 아니다라고 말 할 지도 모르겠습니다.
왜냐하면 그 사람들 말도 일리는 있거든요.

저는 살아있는 박정희를 말하는데 그 사람들은 죽은 박정희를 말하는 거거든요.
죽은 사람한테 어떻게 나쁜놈이니 어떻느니 하는 악담을 할 수 있겠습니까?

제가 박정희를 나쁜 놈이라고 말하는 것은 지금 현재 살아있는 박정희를 보고 하는 말입니다.

지금 박정희가 어떻게 살아 있길래 그 놈은 나쁜 놈일까요?



우리 나라를 구성하는 국민들의 공통된 합의 점이 있습니다.
그 합의점의 중요하다고 생각하는 부분 중 문서화 된 부분이 헌법이구요.
(헌법은 절대적인 것은 아닙니다. 언제든지 수정될 수 있습니다. 하지만 그 방향이 더 중요한 국민들의 공통된 합의점을 반영하기 위할 때만 개선이 될 수 있겠죠.)

그 헌법 정신에 위배되는 즉 아주 기본적인 국민의 합의점에 반하는 그런 행동이나 세력들은 나쁜 놈이라고 말 할 수 있습니다.

우리나라 헌법 정신은 자유 민주주의와 우리민족이 일제와 독재에 저항한 민족 정신을 추구합니다.

저는 자유 민주주의의 가장 중요한 부분이면서 현재 지켜지지 못하고 있는 부분이 공정한 경쟁과 기회의 균등이라고 봅니다.
바로 부패와 비리속에서 성장한 우리나라 경제가 바로 이 공정한 경쟁과 기회의 균등을 억누르고 있다고 봅니다.

이러한 패러다임은 우리의 역사를 통해서 영향을 받아서이겠지만 가장 큰 영향을 준 시기는 바로 근대화 시기이겠죠.
우리나라 근대화에 가장 큰 영향을 미친 사람이 이 시기 18년간 장기집권을 한 박정희일 테구요.

박정희가 18년간 비리와 부패의 경제 패러다임을 구축했기 때문에 나쁜 놈인가?
그렇게 얘기하면 박정희를 지지하는 쪽에서는 이런 저런 사례와 근거와 이유를 대며 박정희는 훌륭한 사람이라고 말 할 겁니다.

그럼 저는 그 얘기를 가만히 듣고 나서 그것만 가지고 박정희를 나쁜 놈이라고 말하는건 곤란하다라고 말 할 겁니다.

생각해 보세요.

한 인간으로서 가장 험난했던 시기인 일제시대와, 해방 그리고 6.25 와 이후의 가난했던 시대....
이 시대를 지냈던 것 만으로도 그 사람은 충분히 존경받을 만한 가치가 있습니다.
그래서 저는 더더욱 우리의 아버지와 할아버지들을 존경하구요.




박정희가 나쁜 놈인 이유는 이 비리와 부패의 아방궁안에서 엄청난 혜택을 받으며 부와 권력을 유지하는 놈들이 박정희를 전면에 내세우면서 자기들의 치부를 감추기 때문입니다.

이렇게 비리와 부패의 혜택을 받은 세력들의 주류는 일제시대부터 기원합니다.
친일파로 일제시대때 교육이며 행정경험이며 사회적인 권력(미디어같은) 그리고 이를 통한 부의 축적같은 혜택을 받은 놈들이 해방후 그리고 박정희 집권시기 비리와 부패의 그늘에서 완벽한 공간을 확보했습니다.

바로 박정희 자신이 친일파이고 죽을 때까지 메이지 유신의 지사들을 존경했으며 그들이 만들었던 일본의 유신시대를 그대로 본받으려고 했기 때문에 이런 친일 세력들이 건재할 수 있었죠.
그리고 박정희의 독재속에서 그들은 많은 혜택을 받으며 승승장구 할 수 있었습니다.

자 헌법 정신에는 자유경쟁과 공정한 기회가 생명인 자유민주주의를 지향하고 외세와 독재에 저항한 민족정신을 추구하고 있습니다.
하지만 이 비리와 부패세력들은 이 기본적인 헌법정신에 떳떳하지 못한 존재들입니다.

이들은 자신들이 떳떳하지 못하기 때문에 비슷한 박정희를 허황되게 신격화를 하면서 띄우는 겁니다.
경제를 발전시킨 민족의 영웅인것 처럼 박정희를 추대하면서 박정희의 친일 전력과 독재 그리고 비리와 부패 패러다임은 아무것도 아닌 것 처럼 만들어 버리는 거죠.
그래야지만 자신들의 친일 전력과 독재에 협조하고 비리 부패 패러다임에서 안주했던 악행을 숨길수 있고 그로 인해 취득한 부와 권력을 계속 유지할 수 있기 때문이죠.

저는 죽은 박정희는 그 험난하고 어려운 시기를 견뎌낸 우리의 아버지와 할아버지들과 마찬가지로 존경받아야 한다고 생각합니다.
그리고 그 시대적인 상황에서 행한 여러 일들.. 친일과 독재와 근대화와 뭐 그런 것들을 제대로 평가 받아야 합니다.

지금은 떳떳하지 못한 세력들이 자신들의 떳떳하지 못한 부분을 가리려고 박정희를 신격화 하는 바람에 그는 제대로 평가받지 못하고 있습니다.

바로 그 이유 때문에 지금 박정희는 나쁜 놈으로 살아 있는 겁니다.





박근혜가 진정 자신의 아버지인 박정희를 위한다면 박정희를 그 비리와 부패세력으로 부터 떼어 내야 합니다.
그 때의 시대 정신이 가난 극복이었다면 지금의 시대정신은 진정한 자유민주주의의 실현과 복지사회 건설입니다.

대통령이 되서도 그 때 그시절 사람들에 둘러싸여 계속 떳떳하지 못한 세력들의 편에서 통치를 한다면 영원히 자신의 아버지를 나쁜 놈으로 만드는 것입니다.

한홍구 교수는 '이제 드디어 박정희에 대한 환상이 박근혜에 대한 환멸로 묻히게 됐다'고 말했습니다.

박근혜는 지금 박정희를 비리 부패 세력으로 부터 떼어내서 여느 우리의 아버지와 할아버지 처럼 존경받는 인물로 만들 것이냐
아니면 계속 그 친일 비리 부패 세력에게 아버지가 이용당해서 영원히 나쁜 놈으로 기록되게 할 것이냐 이 둘 중의 하나를 할 수 있는 위치에 있습니다.

하지만 역사를 바라보는 눈이라던가 민족의식, 정치 의식 심지어는 넓고 깊게 사고하는 정치인의 능력의 관점에서 볼 때 전자쪽으로 가는 것은 불가능해 보입니다.

어쨌든 박근혜는 효녀 노릇을 할 것 같습니다.
자신의 무능력을 통해서 비리 부패세력들이 만들어 놓은 박정희 환상을 깨뜨릴 것 같기 때문입니다.
그 환상이 깨지고 그것이 현실에 반영돼 비리 부패 세력들의 입지가 좁아지고 좀 더 공정한 사회 진정한 자유민주주의가 실현되고 민족 정신이 되살아나 우리나라가 더 부강해 질 것이기 때문입니다.

전자의 방법으로 된다면 훨씬 더 좋겠지만 아쉽게도 박근혜에게는 그런 능력이 없어 보입니다.

저는 박정희를 우리 아버지들과 할아버지들 처럼 그 어려운 시대를 힘들게 견뎌낸 조상으로서 존경하고 싶습니다.
그런 존경받는 인물로 박정희를 만들고 싶습니다.

그래서 현실에서 비리 부패 세력에 의해서 만들어진 박정희 환상을 깨버리고 그 세력들은 일소하고 진정한 헌법 정신이 실현되는 사회를 만들기 위해 노력할 것입니다.

지금 현실에 살아있는 박정희는 분명히 나쁜 놈입니다.
하지만 그는 환상에서 깨어나서 충분히 존경받는 인물이 되어야 합니다. 우리의 아버지 어머니 그리고 할아버지 할머니들처럼.....


반응형

TableFixture Tutorial (FitNesse)

2013. 8. 14. 22:02 | Posted by 솔웅


반응형

TableFixture


TableFixture 는 FitNesse package의 additional class 입니다. (core FIT fixture set 에는 존재하지 않는 겁니다.  FitNesse와 같은 라이브러리의 한 부분으로서 다뤄지고 있습니다.). 반복적인 구조를 가지고 있지 않은 free-form table들을 실행시킬 때 사용합니다.

Table Format


TableFixture로 어떤 포맷인지 어떤 셀을 테스트할 것이지 등을 정하실 수 있습니다. 제한점이 있다면 첫번째 줄은 fixture의 클래스 이름이어야 한다는 것 뿐입니다. 나머지는 여러분 마음대로 하셔도 됩니다. 기존의 인보이스나 reports 혹은 document들을 FitNesse test로 바꿀 때 사용하실 수 있습니다. 아래 예제들은 Test Driven .NET Development with FitNesse 에서 가져온 것입니다. 인보이스를 세금계산으로 verify 하겠습니다.

!|TableFixtureTest|
|Item|Product code|Price|
|Pragmatic Programmer|B978-0201616224|34.03|
|Sony RDR-GX330|ERDR-GX330|94.80|
|Test Driven Development By Example|B978-0321146533|32.39|
|Net Total||161.22|
|Tax (10% on applicable items)||9.48|
|Total||170.70|


Fixture class


이 fixture class를 사용하려면  fitnesse.fixtures를 extend 해야 합니다. doStaticTable(int rows) method를 override 합니다. 그 메소드에서 getText(row, column)으로 관계된 cell들의 내용들을 추려내서 table을 process 하는 겁니다. test cell들을 right(row,column)로 correct 하거나 wrong(row,column,actualValue)로 incorrect 하도록 test cell들을 mark 하실 수 있습니다.

아래 예제는 아래에서부터 두번째 줄의 세번째 cell에 있는 값고 매치되는 인보이스로부터 total tax를 verify 하는 에제입니다.

Java Source Code

package info.fitnesse.fixturegallery;

import info.fitnesse.fixturegallery.domain.TaxCalculator;
import fitnesse.fixtures.TableFixture;

public class TableFixtureTest extends TableFixture{
	protected void doStaticTable(int rows) {
		 TaxCalculator tc=new TaxCalculator();
	      double totaltax = 0;

	      for (int row = 1; row < rows - 3; row++)
	      {
	        totaltax += tc.GetTax(getText(row, 1),
	          Double.parseDouble(getText(row, 2)));
	      }
	      double taxintable = Double.parseDouble(getText(rows - 2, 2));
	      if (taxintable == totaltax)
	        right(rows - 2, 2);
	      else
	        wrong(rows - 2, 2,String.valueOf(totaltax));
	    }
}


.NET Source Code

using System;
using System.Collections.Generic;
using System.Text;

namespace info.fitnesse.fixturegallery
{
    public class TableFixtureTest : global::fitnesse.fixtures.TableFixture
    {
        protected override void DoStaticTable(int rows)
        {
            TaxCalculator tc = new TaxCalculator();
            decimal totaltax = 0;
            for (int row = 1; row < rows - 3; row++)
            {
                totaltax += tc.GetTax(GetString(row, 1),
                  Decimal.Parse(GetString(row, 2)));
            }
            decimal taxintable = Decimal.Parse(GetString(rows - 2, 2));
            if (taxintable == totaltax)
                Right(rows - 2, 2);
            else
                Wrong(rows - 2, 2, totaltax.ToString());
        }
    }

}

Python Source Code

from info.fitnesse.fixturegallery.domain.TaxCalculator import TaxCalculator
from fitnesse.fixtures.TableFixture import TableFixture

class TableFixtureTest(TableFixture):
    def doStaticTable(self, rows):
        tc = TaxCalculator()
        totalTax = 0.0

        for row in range(1, rows - 3):
            totalTax += tc.getTax(self.getText(row, 1),
                                  float(self.getText(row, 2)))

        taxinTable = float(self.getText(rows - 2, 2))
        if taxinTable == totalTax:
            self.right(self.getCell(rows - 2, 2))
        else:
            self.wrong(self.getCell(rows - 2, 2), str(totalTax))

Notes


정수형으로 변환된 cell 값을 retrieve 할 때 getInt 를 사용하시면 됩니다.

Usage


다른 fixture type으로는 구현하기 힘든 특정 business-specific table 포맷에 대해서 테스트 하기를 원하신다면 이 TableFixture를 사용하시는게 좋습니다. HTML table로 export 될 수 있는 문서를 가지고 있다면 더 쉽게 테스트를 구현하실 수 잇습니다. 그 HTML을 FitNesse로 곧바로 붙여넣기 하면 될 테니까요.


반응형

RowFixture Tutorial (Fitnesse)

2013. 8. 14. 21:43 | Posted by 솔웅


반응형

RowFixture



RowFixture 는 객체들의 다이나믹한 리스트를 테스트합니다. Expected list (FitNesse Table)와 실제 결과 리스트 (fixture code로부터 도출된)를 비교하게 됩니다. 그리고 추가되고나 missing 된 아이템들을 report 하게 되는 거죠.

Table Format


테이블의 첫번째 줄은 fixture class 이름 입니다. 두번째 줄은 리스트 내의 객체들 구조를 나타내구요. (verify 하기를 원하는 프로퍼티들이나 메소드들이 되겠죠.). 그 이후에 나오는 줄들은 배열에 있는 expected objects 들입니다.

!include -seamless SetUpFixture

!|RowFixtureTest|
|name|post code|
|John Smith|SW4 66Z|
|Michael Jordan|NE1 8AT|


Fixture class


이 fixture class는 fit.RowFixture 를 extend 해야 하고 아래 두개의 메소드들을 오버라이드 해야 합니다.

  • getTargetClass — returns the Type or Class object representing the type of objects contained in the array.
  • query — returns the actual array of objects to be verified.
# section Java Source Code

Java Source Code

package info.fitnesse.fixturegallery;

import info.fitnesse.fixturegallery.domain.Player;
import fit.RowFixture;

public class RowFixtureTest extends RowFixture{
	public Class getTargetClass() {
		return Player.class;
	}
	public Object[] query() throws Exception {
			return Player.players.toArray();
	}
}

.NET Source Code

using System;
using System.Collections.Generic;
using System.Text;

namespace info.fitnesse.fixturegallery
{
    public class RowFixtureTest: fit.RowFixture
    {
        public override Type GetTargetClass()
        {
            return typeof(Player);
        }
        public override object[] Query()
        {
            return Player.players.ToArray();
        }
    }
}

Python Source Code

from fit.RowFixture import RowFixture
from info.fitnesse.fixturegallery.domain.Player import Player

class RowFixtureTest(RowFixture):
    def getTargetClass(self):
        return Player

    def query(self):
        return list(Player.players) #< Return copy of players

Notes


그 객체가 identity (primary key 같은)의 한 부분이 되는 프로퍼티들을 가지고 있다면 그 프로퍼티들의 리스트들은 부가 정보 리스트들의 왼쪽에 놓여지게 됩니다. 이렇게 하면 error report를 보기가 훨씬 쉬워집니다. Figure 1을 봐 보세요. 두 클래스 모두 에러는 같습니다. 하지만 그 컬럼의 순서로 인해 하나는 주요 항목에 대한 에러를 알아보기가 쉽도록 보여주고 다른 하나는 모든 줄이 missing 되 버리게 됩니다.


Figure 1: RowFixture maps rows to objects from left to right



query method 다른 추가적인 argument들을 pass 하도록 허용하지 않습니다. 좀 더 자세한 정보를 보시려면 Fixture Arguments를 보세요.

리스트의 element들의 순서는 상호 의존적이지 않습니다. RowFixture 는 이를 무시할 겁니다.

Usage


객체들의 리스트를 verify 하려면 Use RowFixture 를 사용해서 테스트 하세요. 혹은 리스트 내의 모든 리스트들에 method를 만들어서 실행하셔도 됩니다. (이러면 번거롭겠죠?)


element 의 순서가 중요할 때는 이 RowFixture를 사용하지 마세요. 대신 ArrayFixture를 사용하세요.


반응형