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

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

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

    成就夢想

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      21 隨筆 :: 22 文章 :: 6 評論 :: 0 Trackbacks
            web應用集成測試的時候,各位還需要啟動web容器,然后打開瀏覽器,輸入ulr,然后看到瀏覽器的輸出嗎?

    下面我們用maven做到自動化!


     

    我們利用maven的生命周期和jetty插件來實現。

     

    下面描述下做的自動化web集成測試實現的原理。

    1,在生命周期pre-integration-test啟動jetty容器

    2,在生命周期integration-test中測試我們寫的***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>

     

    然后就可以編寫測試用例了

     

     步驟如下:

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

    再此不舉例了,主要一個思路可以用httpclint來實現里面的測試代碼。

    2,然后 執行 mvn clean post-integration-test -Pittest

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

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

     



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

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 一级毛片全部免费播放| 最近中文字幕无免费视频| 亚洲精品视频免费在线观看| 日韩不卡免费视频| 精品女同一区二区三区免费播放 | 97人妻精品全国免费视频| 亚洲精品美女久久久久9999| 最新69国产成人精品免费视频动漫| 久久国产精品免费| 亚洲国产成人91精品| 亚洲国产成人爱av在线播放| 毛片无码免费无码播放 | 亚洲国产成人手机在线观看| 国产亚洲精久久久久久无码AV| 91短视频免费在线观看| 国产精品亚洲专区无码WEB| 亚洲国产精品无码久久久不卡| 免费的涩涩视频在线播放| 免费在线看黄网站| 亚洲国产AV无码一区二区三区| 亚洲AV无码一区二区二三区软件| 日韩精品视频免费在线观看| 日本在线看片免费人成视频1000 | 污污免费在线观看| 亚洲一级免费视频| 国产亚洲精品观看91在线| 国产精品免费_区二区三区观看 | 免费无码A片一区二三区| 在线看片免费人成视频福利| 色噜噜噜噜亚洲第一| 亚洲午夜精品在线| 久久亚洲一区二区| 亚洲中文字幕无码一久久区| 国产无遮挡裸体免费视频| 台湾一级毛片永久免费| 毛片免费在线观看| 两个人日本免费完整版在线观看1| 亚洲成a人片在线不卡一二三区| 亚洲国产精品成人综合久久久| 亚洲av无码成h人动漫无遮挡| 亚洲男人天堂2020|