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

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

ConstraintFixture



ConstraintFixtureCalculateFixtre의 변형 입니다. (see CalculateFixture) 이 ConstraintFixture는 각 calculation에 대한 true 값을 기대합니다.



Table Format



테이블의 첫번째 row는 fixture class 이름입니다. 그 다음 두번째 row에는 input parameter의 이름이 들어갑니다. 그 다음에 오는 모든 줄에는 input parameter의 값들을 넣구요.


!|ConstraintFixtureTest|
|firstPart|secondPart|
|1|2|
|2|3|





Fixture class

이 fixture class는 fitlibrary.ConstraintFixture를 extend 합니다. 여기에는 모든 파라미터 이름들로부터 나온 boolean method를 정의해야 합니다. (아래 예제의 경우에는 firstPartSecondPart이 됩니다.)



Java Source Code



package info.fitnesse.fixturegallery;

import fitlibrary.ConstraintFixture;

public class ConstraintFixtureTest extends ConstraintFixture{
    public boolean firstPartSecondPart(int firstPart,int secondPart){
        return firstPart<secondPart;
    }
}




.NET Source Code



using fitlibrary;
using System;

namespace info.fitnesse.fixturegallery
{
    public class ConstraintFixtureTest: ConstraintFixture
    {
        public bool FirstPartSecondPart(int  firstPart,int secondPart)
        {
            return firstPart<secondPart;
        }
    }
}




Python Source Code


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

class ConstraintFixtureTest(ConstraintFixture):
    _typeDict = {}

    # PY3K: firstPartSecondPart(firstPart : int, secondPart : int) : bool
    _typeDict["firstPartSecondPart.types"] = [ "Boolean", "Int", "Int" ]
    def firstPartSecondPart(self, firstPart, secondPart):
        return firstPart < secondPart      


       


SetFixture




SetFixture는 한가지만 빼고는 ArrayFixture와 같습니다. (see ArrayFixture) 다른점은 row의 순서가 체크되지 않는다는 겁니다.



Notes



자바 flow mode 에서는 flow fixture method에서 return 된 set들이 자동적으로 SetFixture에 매핑됩니다.


Usage



자바에서는 JavaBean object를 사용할 때 RowFixture 대신에 SetFixture를 사용하세요. 왜냐하면 이 fixture가 JavaBeans getter에 대해 정확하게 기능을 제공하거든요. element들의 순서가 그렇게 중요하지 않을 때는 이 SetFixtureArrayFixture 대신에 사용하셔도 됩니다.



SubsetFixture



SubsetFixtureSetFixture의 변형입니다. (see SetFixture)  fixture table에 있는 row가 실제 row들의 subset이 될 수 있다는 부분 만 다릅니다.



Usage


잔여 element들을 무시하기를 원하신다면 RowFixtureSetFixture 대신에 이 SubsetFixture를 사용하세요. (예를 들어 같은 데이터베이스 테이블안에 있는 다른 row들은 상관하지 않고 데이터베이스의 어떤 row들의 존재를 체크하고 싶은 경우 등을 들 수 있습니다.)

반응형

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들에 대해 제대로 작동할 것이기 때문이죠.

반응형