Whiteship's Note

WebTUnit 1.0 M1 배포합니다.

모하니?/Coding : 2009.05.19 21:43


아래 매뉴얼을 참조하세요.
영어로 작성했는데, 너그러이 봐주세요.

이번 주 내로 배포하고 싶은.. M2 버전에서는 다음 두 가지를 중점접으로 다루겠습니다.
- 샘플 애플리케이션을 추가
- Jetty 추가

저저번주 금요일부터 오늘까지 달렸으니까..
금,  월~금, 월, 화. 8일이네요.
이제 쬐끔 쓸만해져서 공개했습니다.

웹 테스트 하실 때 조금이나마 보탬이 되었음 합니다.
막심 므라비차의 축하공연을 들으며 찬찬히 읽어 보세요. 간단합니다.



0. add repository setting to pom.xml or settings.xml

        <repository>
            <id>opensprout nexus</id>
            <name>OpenSprout Nexus public</name>
            <url>http://www.opensprout.org/nexus/content/groups/public</url>
        </repository>

        WebTUnit is provided by OpenSprout Nexus.

1. add dependency to pom.xml

        <!-- WebTUnit -->
        <dependency>
            <groupId>org.opensprout</groupId>
            <artifactId>webtunit</artifactId>
            <version>1.0-M1</version>
        </dependency>

2. add cargo-maven-plugin and maven-surefire-plugin to pom.xml

    2-1. cargo-maven-plugin configuraion

        <build>
        ...
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.0.1-SNAPSHOT</version>
                <configuration>
                    <wait>false</wait>
                    <container>
                        <containerId>tomcat6x</containerId>
                        <type>installed</type>
                        <home>tomcat/apache-tomcat-6.0.18</home>
                    </container>
                    <deployer>
                        <type>installed</type>
                    </deployer>
                    <configuration>
                        <properties>
                            <cargo.servlet.port>8080</cargo.servlet.port>
                        </properties>
                    </configuration>
                </configuration>
                <executions>
                    <execution>
                        <id>start-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-container</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        First, you must set up your tomcat home to <home> element above or,
        just download and unzip tomcat archive to project/tomcat folder.

        If you set <wait> to true, then when you run a test server by 'mvn cargo:start',
        the console will be wait untile you stop the process by CTRL + C.
        This is useful when you want to test on Eclipse by CTRL + ALT + X -> T or CTRL + F11.
        But, you shold be careful when you use phase that through pre-integration-test phase.
        That process will stop and wait in pre-integration-test until you stop the test server.

        By default setting, you can use cargo with phases thar through pre-integration-test phase.
        For example, when you run 'mvn verify', you will pass pre-integration-test phase,
        but you will not be stopped by process, because it dooesn't wait.
        This will help you when you set up this project in continuous integration environment.

    2-2. maven-surefire-plugin configuration

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/*WebTest.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                            <excludes>
                                <exclude>none</exclude>
                            </excludes>
                            <includes>
                                <include>**/*WebTest.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        ...
        </build>

        If you want to use another naming pattern, or package pattern,
        change '**/*WebTest.java' value to what you want.

3. make some web test with webdriver.

    @RunWith(WebTestRunner.class)
    @WarConfiguration("opensprout")
    public class MemberWebTest {

        @WebTest
        public void memberPages(){
            WebDriver driver = new HtmlUnitDriver();
            driver.get("http://localhost:8090/springsprout/member/list.do");
            MemberListPage listPage = PageFactory.initElements(driver, MemberListPage.class);
            assertEquals(2, listPage.getTableRows());
        }
    }

    If you want to feel comfortable when you write some web test codes,
    I recommend Page Object Pattern(http://code.google.com/p/webdriver/wiki/PageObjects).
   
    You can also use @DataConfiguration when you want to input and delete some test data.
    Check some usecases.
    - http://whiteship.me/2237
    - http://whiteship.me/2238
    - http://whiteship.me/2239

4. run test.

    Open a console, type 'mvn verify'.
    Or, modify, cargo-maven-plugin's <wait> to true, and run it with JUnit in Eclipse.
   
5. give me a feedback

    http://github.com/whiteship/WebTUnit/issues
   

top

  1. Favicon of http://yunsunghan.tistory.com BlogIcon Max 2009.05.20 08:28 PERM. MOD/DEL REPLY

    아직 뭐하는놈인지 자세히 안봤지만, 소스코드를 대충 보니, 대단히 발전적이네요.
    멋져요. 화이팅 입니다.^^*

    Favicon of https://whiteship.tistory.com BlogIcon 기선 2009.05.20 08:56 신고 PERM MOD/DEL

    넵 첫인상이 좋은 듯 하여 다행이네요. ^^

  2. Favicon of https://helols.tistory.com BlogIcon is윤군 2009.05.21 10:18 신고 PERM. MOD/DEL REPLY

    결국 세상에 나오네요 ;;ㅋㅋ ㅊㅋㅊㅋ!

    Favicon of http://whiteship.me BlogIcon 기선 2009.05.22 09:49 PERM MOD/DEL

    결국 나만 쓸 것 같은 프로젝트.ㅋㅋ

  3. Favicon of http://blog.lckymn.com BlogIcon Kevin 2009.05.22 00:03 PERM. MOD/DEL REPLY

    http://pds6.egloos.com/pds/200712/16/83/a0016483_4765140c798ff.jpg

    시작한지 얼마 안된거 같은데 금새 만드셨네요. 축하드립니다. :)

    Favicon of http://whiteship.me BlogIcon 기선 2009.05.22 09:49 PERM MOD/DEL

    넹 감사합니다.ㅎㅎㅎ

Write a comment.




: 1 : ··· : 132 : 133 : 134 : 135 : 136 : 137 : 138 : 139 : 140 : ··· : 299 :