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

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

Maven Information


Maven을 사용하신다면 아래에 central Maven repository에서 Maven artifacts를 보실 수 있습니다.

 http://repo1.maven.org/maven2/org/seleniumhq/selenium/

DefaultSelenium이나 Maven 프로젝트의 WebDrever 중 하나를 사용하시려면 pom.xml에 아래 dependency를 추가하세요.

   

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.35.0</version>
    </dependency> 



Note: 2.0,rc3 이전 버전은 이 artifact 이름이 selenium-remote-control입니다.

다른 Maven artifacts를 보시려면 diagram을 보세요. Selenium Maven artifacts와 그 artifacts의 주요한 클래스들과 인터페이스들을 보실 수 있습니다.






특정 WebDriver implementation만을 사용하시려면 (예를 들어 FirefoxDriver 만 사용한다든지), selenium-java artifact 를 사용하지 않으셔도 됩니다. 여기에는 많은 transitive dependency들이 있습니다. 이것을 사용하는 대신 간단히 아래와 같은 dependency를 추가하시면 됩니다.

   

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.35.0</version>
    </dependency> 


DefaultSelenium이나 RemoteWebDriver implementation 을 사용한다면 Selenium server를 사용해야 합니다. Selenium Downloads page  에서 selenium-server-standalone.jar를 다운 받으세요. 그리고 여러분 프로젝트에 이 Selenium 서버를 embed 하시면 됩니다. pom.xml 파일에 아래 dependency를 추가해 주세요.
 
   

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.35.0</version>
    </dependency> 



이제 SeleniumServer 인스턴스를 생성하실 수 있습니다.

selenium-server artifact는 servlet-api-2.5 artifact에 대한 dependency를 가지고 있다는 것을 명심하세요. 여러분 프로젝트가 웹 어플리케이션 컨테이너 안에서 실행된다면 여러분은 이것을 exclude 하셔야 합니다.


Third Party Browser Drivers NOT SUPPORTED/DEVELOPED by seleniumhq


Opera Driver

   

<dependency>
        <groupId>com.opera</groupId>
        <artifactId>operadriver</artifactId>
        <version>1.5</version>
    </dependency> 




PhantomJSDriver (GhostDriver)

  

<dependency>
        <groupId>com.github.detro.ghostdriver</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.0.4</version>
    </dependency> 
 



반응형


반응형

Selenium WebDriver 관련 공부 하고 있습니다.

Youtube 에서 관련 Tutorial 찾아서 공부한 내용 정리합니다.


이 Tutorial 을 올린 애는 Ashish Thakur 로 홈페이지는 www.qtpselenium.com 입니다.




WebDriver 는 RC 의 확장된 버전입니다.

Selenium WebDriver는 Selenium 2 라고도 하는데 이걸로 요즘 나오는 모바일에 있는 웹브라우저용으로 테스트 케이스를 만들 수 있습니다.


우선 설치하는 방법은 아래와 같습니다.


1. Java를 인스톨 한다.
2. 이클립스 IDE for Java EE developers (Indigo Package) 를 다운 받는다.
3. Eclips 를 Run 한다. (Java 가 인스톨 돼 있어야 함)
   64bit일 경우 jdk 를 다운 받는다. (32bit면 그냥 JRE만 다운 받아도 될 것임)
4. Workspace 를 설정한다.
5. File-New-Project-Java-Java Project
   -> Project Name -> Finish
6. src right click -> New -> Class : 클래스 파일을 하나 만든다.

* Selenium 을 하려면 Java에 대해 알아야 한다.
* http://selenium.googlecode.com/git/docs/api/java/index.html 로 가면 Selenium에 대한 JavaDoc이 나옴

7. http://www.seleniumhq.org/download/ 로 가서 Selenium 을 다운로드 받는다. (Java 버전으로)
8. Project - Properties - Java Build Path - Libraries Tab - Add External Jars - selenium-lib 에 있는 모든  jar파일과 selenium-java-2.35.0.jar,selenium-java-2.35.0-srcs 들을 include 한다.


설치는 이렇게 하시면 됩니다.


그러면 FireFox, Chrome 그리고 IE 웹 브라우저용 WebDriver를 사용하는 예제를 보겠습니다.


import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class Browsers {

    public static void main(String[] args) {
        FirefoxDriver d1 = new FirefoxDriver();
        d1.get("http://gosolkit.com");
       
        String path = System.getProperty("user.dir"); // current path of project
        System.setProperty("webdriver.chrome.driver",path + "\\chromedrive\\chromedriver.exe");
        ChromeDriver d2 = new ChromeDriver();
        d2.get("http://coronasdk.tistory.com");
       
        System.setProperty("webdriver.ie.driver",path + "\\iedrive\\IEDriverServer.exe");
        InternetExplorerDriver d3 = new InternetExplorerDriver();
        d3.get("http://www.qtpselenium.com");
       
        String title = d1.getTitle();
        System.out.println(title);
    }

}


이 클래스가 있는 project에서는 selenium 관련 jar 파일들이 모두 include 돼 있어야 합니다.


우선 첫번째로 Firefox를 사용하는 방법은요 그냥 FirefoxDriver() 객체를 하나 만들어서 사용하면 됩니다.

위 예제에서는 제 개인 싸이트를 get 했습니다.


두번째로 Chrome 을 사용할 때는 chromedriver.exe 를 설치 해야 됩니다.

다운 받는 장소는 http://www.seleniumhq.org/download/ 로 가셔서 찾아보시면 링크가 걸려 있을 겁니다. 


잘 못 찾겠으면 http://code.google.com/p/chromedriver/ 로 가셔서 다운 받으시면 됩니다.


다운 받으신 후 해당 프로젝트에 chromedriver 폴더를 만들고 그 안에 chromedriver.exe 파일을 복사해 넣습니다.



그리고 사용법은 webdriver.chrome.driver 를 사용해서 해당 exe 파일이 있는 경로가 있는 프로퍼티를 세팅해야 합니다.

여기서 현재 작업하고 있는 경로를 알 수 있는 System.getProperty("user.dir"); 를 사용하시면 좀 더 편하게 설정하실 수 있습니다.


이 프로퍼티를 설정하셨으면 ChromeDriver객체를 만드시면 됩니다.

위 예제에서는 get 을 사용해서 제 블로그를 이 크롬브라우저에 세팅했습니다.


그 다음은 IE 인데요. 이것도 Chrome 과 마찬가지로 http://www.seleniumhq.org/download/ 로 가셔서 해당 링크를 찾으세요. 

아니면 그냥 http://code.google.com/p/selenium/downloads/detail?name=IEDriverServer_x64_2.35.3.zip 로 가셔서 다운 받으셔도 됩니다. 


크롬 브라우저와 마찬가지로 인터넷 익스플로러도 webdriver.ie.driver 를 사용해서 프로퍼티를 세팅해 주세요.



그 다음에 InternetExplorerDriver 객체를 만드시면 됩니다.

위 예제에서는 제가 공부한 유튜브 강좌를 올린 Ashish 의 웹사이트를 get 해서 이 IE 브리우저에 세팅했습니다.


이렇게 객체를 세팅하고 나면 get() 으로 얻은 웹페이지에 있는 여러 element들의 정보를 가져오거나 event를 발생시켜서 테스트 케이스를 만들 수 있습니다.


위 예제에서는 간단하게 첫번째에 세팅한 ForefoxDriver로 제 웹사이트의 페이지 title을 얻어와서 콘솔에 뿌려지도록 만들었습니다.


위 클래스를 실행시키면 (Mouse right click -> Run As -> Java Application) Firefox 브라우저가 실행되서 gosolkit.com 페이지가 뜨고 크롬 부라우저에는 이 블로그가 그리고 마지막으로 IE 브라우저에는 Ashish의 웹페이지가 뜰 겁니다.


작업이 다 끝나면 콘솔에 제 웹사이트인 gosolkit.com 의 title이 찍힙니다.


반응형

java memo 두 날짜 사이 일 수 구하기

2013. 9. 5. 01:15 | Posted by 솔웅


반응형
처음으로 모바일로 글을 올리네요.

일 하다가 기억해 두고 싶은 로직이 나와서.....

두 날짜 사이의 일 수 구하는 공식

public int daysBetween (Date d1, Date d2) {
return (int)((d2.getTime() - d1.getTime()) / (1000*60*60*25));
}

포물선 운동 표현 하는 공식

h=vo.sin@.t-1/2.g.t**2(g:gravity acceleration constant 9.8)
I=vo.cos@.t


iPhone 에서 작성된 글입니다.
반응형


반응형

Hannah Anderson Dismisses Critics, Explains Relationship with James DiMaggio

By Tim Nudd

08/22/2013 at 07:45 AM EDT 




Less than two weeks after her dramatic rescue, Hannah Anderson pushed back on Thursday at critics who have questioned her relationship with her abductor, James Lee DiMaggio – saying the letters and text messages she sent him were completely innocent.

극적으로 구출된지 2주일도 안되는 Hannah Anderson은 납치범 James Lee DiMaggio와의 관계에 의문을 가지는 의견들에 대해 응답했다. 그녀가 납치범에게 보낸 편지들과 문자메세지들은 범죄와는 상관 없는 일이라고 말했다.

On the very day she was abducted, Anderson, 16, reportedly sent as many as 13 texts to DiMaggio, who is suspected of killing Hannah's mother Christina, 44, and brother Ethan, 8, before being killed himself during an arrest attempt by the FBI.

그녀가 납치된 날 Anderson(16)은 그녀의 어머니인 Christina(44)와 남동생 Ethan(8)을 살해한 것으로 의심되는 DiMaggio에게 13통의 문자 메세지를 보냈다고 알려졌다. (DiMaggio는 납치 후 FBI에게 체포되는 과정에서 살해 당했다.)





But Hannah says the texts can be explained.

Hannah는 그 문자메세지에 대해서는 충분히 설명할 수 있다고 말했다.

"He was picking me up from cheer camp, and he didn't know the address or where I was," she said on the Today show. "So I had to tell him the address and tell him that I was going to be in the gym and not in front of the school, just so he knew where to come get me."

"그는 저를 cheer camp (치어리더들의 캠프)에서 pick up 했어요. 그는 그 주소도 몰랐고 제가 어디 있는지 조차 몰랐어요. 그래서 그에게 주소를 알려 줬죠. 그리고 학교 앞이 아니라 체육관에 갈거라고 얘기해 줬어요. 그래서 그가 저를 어디로 오면 만날 수 있는지 알았죠."라고 그녀는 Today show에서 말했다.

Anderson also wrote letters to DiMaggio, but says he was just helping her when she was having troubles.

Anderson은 또한 DiMaggio에게 편지를 썼었다. 그녀는 그 편지에 대해 DiMaggio 가 자신이 어려움에 처해 있을 때 도와줬었다고 말했다.

"The letters were from like a year ago, when me and my mom weren't getting along very well," she says. "Me and him would talk about how to deal with it. I'd tell him how I felt about it, and he'd help me through it. They weren't anything bad. They were just to help me through tough times."

"그 편지들은 한 1년 전 쯤에 썼던 거예요. 그때 제가 제 엄마와 별로 사이가 안 좋았었죠. DeMiggio는 제가 엄마와 사이가 안 좋은데 어떻게 해야 할 지에 대해 의논해 줬어요. 그에게 제 힘든 점을 얘기 했고 그는 저를 도와줬어요. 거기에 어떤 불순한 부분은 없었어요. 그 때 그냥 저를 도와 주려고 했었던 거예요." 




Though she finds herself on the defensive, Anderson says her critics just don't have the facts.

그녀는 그녀가 사실을 밝혔음에도 그녀를 향해 비판을 하는 내용들은 fact들이 없다고 말했다.

"They don't really know the story, so they kind of have their own opinion on what they hear," she says.

"그 사람들은 story를 제대로 알지 못해요. 그냥 그 사람들은 들은 얘기에 대해 자기 나름대로 생각하는 거예요."

She adds: "You are who you are, and you shouldn't let people change that. And you have your own opinion on yourself, and other people's opinions shouldn't matter."

그녀는 또 다음과 같이 덧 붙였다. "당신은 당신일 뿐이예요. 다른 사람들이 그것을 바꿀 수는 없어요. 당신은 당신에 대해 당신만의 견해를 가질 수 있어요. 그리고 다른 사람들은 그것에 대해 뭐라고 할 수 없어요."

Aside from defending herself, Anderson did find time to thank those who helped search for her, which eventually led to an FBI tactical agent killing DiMaggio while trying to arrest him on Aug. 10.

그녀는 자신의 의견을 밝히면서 납치된 그녀를 찾는데 협조한 사람들에 대해 감사의 뜻을 전하기도 했다. (FBI는 8월 10일 납치범 DiMaggio를 체포하는 작전 과정에서 그를 살해했다.)

"I would like to say thank you, because without them, I probably wouldn't be here right now," she says. "I want to thank the horsemen and the Amber Alert and the sheriff and the FBI, with everyone that put in time to find me, and my dad and my friends and my family and just all my supporters that helped spread the word."

"저는 협조한 모든 분들에 대해 감사를 드립니다. 그 분들이 없었으면 저는 여기 있을 수 없었을 거예요. 당시 말을 타고 있었던 분들이랑 Amber Alert 그리고 보안관들과 FBI에 그리고 저를 찾는데 협조해 주신 모든 분들께  감사의 뜻을 전하고 싶어요. 그리고 아빠와 친구들 그리고 제 가족들, 저를 찾는도 도움을 주기 위해 여기저기 납치 소식을 알려주신 모든 분들께도 감사드려요."


Visit NBCNews.com for breaking news, world news, and news about the economy


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


몇주전에 샌디에고에서 한 소녀가 납치되서 Amber Alert 이 발동됐었어요.

납치범이 그 소녀의 집에 불을 질러서 엄마와 남동생을 죽이고 그 소녀를 납치한건데요.


그 범인은 오하이오 주에서 FBI에 체포되는 과정에서 총에 맞아 죽고 그 소녀는 무사히 구출 됐어요.


그 사건이 일어나기 전서부터 그 소녀와 그 납치범은 편지와 문자 메세지를 주고 받을 정도로 친분이 있다는게 알려지면서 많은 이들이 이 사건에 대해 이런 저런 소문이 돌았어요.


저도 뭐가 있나? 하면서 궁금해 했는데 그 소녀가 그에 대해 인터뷰를 통해서 밝힌 기사가 있어서 한번 번역해 봤습니다.



Amber Alert : 정확한지는 모르지만 제가 아는 한에서는 미성년자가 납치됐을 경우 이 Amber Alert 이 발동 되요. 그러면 경찰은 그 지역 거주민의 핸드폰에 관련 내용에 대해 문자 메세지를 보내 협조를 부탁하고 고속도로에 있는 모든 전자 경고판에 사건 관련 안내 내용이 떠요.

제 핸드폰은 뉴저지 지역번호라서 이 문자 메세지를 받지는 못했는데요. (여긴 모바일 번호에만 사용되는 010 같은 게 따로 없고 그냥 일반 번호처럼 지역번호-국번-번호 이렇게 번호가 구성되요.)

이 지역번호로 시작하는 모바일을 가지고 있는 직장동료가 그러는데 그날 막 모바일이 삐삐 거리면서 사건 내용과 범인 자동차 색, 번호 뭐 이런게 문자 메세지로 왔대요. 그리고 출근 길에 고속도로에도 관련 내용이 display 되는 것을 봤다 그러구요. :)

반응형


반응형

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

반응형

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을 출력하게 될 겁니다.

반응형
이전 1 ··· 4 5 6 7 8 9 다음