<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    成就夢(mèng)想

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      21 隨筆 :: 22 文章 :: 6 評(píng)論 :: 0 Trackbacks
            web應(yīng)用集成測(cè)試的時(shí)候,各位還需要啟動(dòng)web容器,然后打開瀏覽器,輸入ulr,然后看到瀏覽器的輸出嗎?

    下面我們用maven做到自動(dòng)化!


     

    我們利用maven的生命周期和jetty插件來實(shí)現(xiàn)。

     

    下面描述下做的自動(dòng)化web集成測(cè)試實(shí)現(xiàn)的原理。

    1,在生命周期pre-integration-test啟動(dòng)jetty容器

    2,在生命周期integration-test中測(cè)試我們寫的***IT.java類

    3,在post-integration-test shutdow jetty容器。

    在pom.xml中加入代碼如下:

    <profiles>
            
    <profile>
                
    <id>ittest</id>
                
    <build>
                    
    <plugins>
                        
    <plugin>
                            
    <groupId>org.apache.maven.plugins</groupId>
                            
    <artifactId>maven-surefire-plugin</artifactId>
                            
    <executions>
                                
    <execution>
                                    
    <id>run-integration-test</id>
                                    
    <phase>integration-test</phase>
                                    
    <goals>
                                        
    <goal>test</goal>
                                    
    </goals>
                                    
    <configuration>
                                        
    <includes>
                                            
    <include>**/*IT.java</include>
                                        </includes>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.mortbay.jetty</groupId>
                            <artifactId>maven-jetty-plugin</artifactId>
                            <version>6.1.26</version>
                            <configuration>
                                <contextPath>/</contextPath>
                                <stopPort>9966</stopPort>
                                <stopKey>stop-jetty-for-it</stopKey>
                                <connectors>
                                    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                        <port>6211</port>
                                    </connector>
                                </connectors>
                            </configuration>

                            <executions>
                                <execution>
                                    <id>start-it-jetty</id>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                    <configuration>
                                        <daemon>true</daemon>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>stop-it-jetty</id>
                                    <phase>post-integration-test</phase>
                                    <goals>
                                        <goal>stop</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </build>
            </profile>
        </profiles>

     

    然后就可以編寫測(cè)試用例了

     

     步驟如下:

    1,定義一個(gè)以此命名的****IT的測(cè)試類(integration test縮寫), 在里面華麗的寫好你的測(cè)試邏輯。

    再此不舉例了,主要一個(gè)思路可以用httpclint來實(shí)現(xiàn)里面的測(cè)試代碼。

    2,然后 執(zhí)行 mvn clean post-integration-test -Pittest

    好了 就可以看到我們測(cè)試用例是否通過。

    建議:以上的代碼可以加入到父類的pom中,以后繼承此父pom后,只需要按以上2步,就可以做到web應(yīng)用測(cè)試自動(dòng)化了。

     



    posted on 2012-04-21 11:57 iamct 閱讀(3113) 評(píng)論(0)  編輯  收藏 所屬分類: 項(xiàng)目管理

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲精品免费视频| 亚洲视频在线精品| 亚洲视频小说图片| 99久久免费看国产精品| 亚洲国产高清在线| 91精品啪在线观看国产线免费| 亚洲国产精华液网站w| 国产成人无码区免费内射一片色欲 | 一级视频免费观看| 亚洲中文字幕日产乱码高清app| 无码毛片一区二区三区视频免费播放| 国产免费无遮挡精品视频| 天堂亚洲免费视频| 亚洲国产精彩中文乱码AV| 免费A级毛片无码A∨免费| 亚洲av乱码一区二区三区香蕉| 成人超污免费网站在线看| 国产亚洲综合久久| 亚洲午夜国产精品无码老牛影视| 中国在线观看免费的www| 亚洲黄色三级网站| 最近免费中文字幕视频高清在线看| 国产精品亚洲lv粉色| 久久影院亚洲一区| 最近中文字幕无免费| 亚洲粉嫩美白在线| 久久亚洲AV永久无码精品| 日韩免费电影网站| 亚洲人成小说网站色| 免费中文字幕在线| 亚洲一区免费观看| 大桥未久亚洲无av码在线| 亚洲不卡中文字幕无码| 免费国产黄线在线观看| 成人免费观看男女羞羞视频| 亚洲a一级免费视频| 日本一道一区二区免费看 | 好紧我太爽了视频免费国产| 亚洲综合网美国十次| 国产精品麻豆免费版| 精品视频一区二区三区免费|