rss

Selenium Acceptance/Integration Tests for a Google App Engine application using maven-gae-plugin

Hi,
 this is just a little tip on how to setup selenium acceptance tests for a Google App Engine java application when using maven-gae-plugin.
  • First, be sure you are using an earlier version (> 0.9.6 release ; eg. the latest snapshot version) of maven-gae-plugin.
    Here is an extract of a pom for the plugin repository and selenium deps right here :

  <properties>  
     <selenium.version>2.15.0</selenium.version>  
     <maven-gae-plugin.version>0.9.7-SNAPSHOT</maven-gae-plugin.version>  
   </properties>  


 <pluginrepositories>  
     <pluginrepository>  
       <id>sonatype.snapshots</id>  
       <url>https://oss.sonatype.org/content/repositories/snapshots/</url>  
       <releases><enabled>true</enabled></releases>  
       <snapshots><enabled>true</enabled></snapshots>  
     </pluginrepository>  
 </pluginrepositories>  
     <!-- acceptance tests -->  
     <dependency>  
       <groupid>org.seleniumhq.selenium</groupid>  
       <artifactid>selenium-java</artifactid>  
       <version>${selenium.version}</version>  
       <scope>test</scope>  
     </dependency>  

  • Then, map the gae-start and gae-stop executions to the pre/post integration phases. This is an example of the plugin configuration :
      <plugin>  
         <groupid>net.kindleit</groupid>  
         <artifactid>maven-gae-plugin</artifactid>  
         <version>${maven-gae-plugin.version}</version>  
         <configuration>  
           <unpackversion>${gae.version}</unpackversion>  
           <serverid>appengine.google.com</serverid>  
           <appdir>${webappDirectory}</appdir>  
         </configuration>  
         <executions>  
           <execution>  
             <id>unpack</id>  
             <phase>validate</phase>  
             <goals>  
               <goal>unpack</goal>  
             </goals>  
           </execution>  
           <execution>  
             <id>deploy</id>  
             <goals>  
               <goal>deploy</goal>  
             </goals>  
           </execution>  
           <execution>  
             <id>gae-start</id>  
             <phase>pre-integration-test</phase>  
             <goals>  
               <goal>start</goal>  
             </goals>  
             <configuration>  
               <appdir>${webappDirectory}</appdir>  
               <port>9000</port>  
               <address>0.0.0.0</address>
               <sdkdir>${gae.home}</sdkdir>  
               <wait>false</wait>  
               <disableupdatecheck>true</disableupdatecheck>  
             </configuration>  
           </execution>  
           <execution>  
             <id>gae-stop</id>  
             <phase>post-integration-test</phase>  
             <goals>  
               <goal>stop</goal>  
             </goals>  
           </execution>  
         </executions>  
         <dependencies>  
           <dependency>  
             <groupid>net.kindleit</groupid>  
             <artifactid>gae-runtime</artifactid>  
             <version>${gae-runtime.version}</version>  
             <type>pom</type>  
           </dependency>  
         </dependencies>  

  • The next and last step is to write your acceptance test. Here is just a simple example :
 package net.mademocratie.gae.acceptancetest;  
 import org.junit.After;  
 import org.junit.Before;  
 import org.junit.Test;  
 import org.openqa.selenium.WebDriver;  
 import org.openqa.selenium.firefox.FirefoxDriver;  
 import static com.thoughtworks.selenium.SeleneseTestBase.assertEquals;  
 public class HomePageIT {  
   private WebDriver driver;  
   @Before  
   public void setUp() {  
     driver = new FirefoxDriver();  
   }  
   @Test  
   public void home_page_should_be_displayed() {  
     this.driver.get("http://localhost:9000");  
     assertEquals("Ma Democratie", this.driver.getTitle());  
   }  
   @After  
   public void tearDown() {  
     driver.quit();  
   }  
 }  

You should find a full running sample on the github repository of ma-dem-ae.
NB: (possible) related issue #5
PS: thanks to codeformatter for this post ;)
PS(bis): oO i just heard that CasperJS or cucumber.js could do the job too...

Aucun commentaire:

Enregistrer un commentaire

Mots clés du blog

acceptancetest androï Android androïd Android7 api appender appengine application applications archive array assistantematernelle astuce auth0 authentication authority automation Axis bash bearer blog bower build bundle c calendrier camille combal cdi certificate cf client cloudfoundry collaboratif command commandes connexion console css démasquées démasquer développement dll dump easter eggs écologie écrit employeur EMUI EMUI5.0 enfant évènement export-package ExtJS fiche find firefox gadget gelf gem git gmail gooelappengine google gparted gps graylog grenoble Grid gui harddrive heroku hover howto HTML http https IE ihm immobilier imprimante innovation insolite instance integration Java JavaScript jenkins jeu jobs json json-schema-validator key keystore labs linux livre log log4j logger logs lombok masquées masquer maven maven-gae-plugin Mémoire microsoft mobile mockito mondialisation monitor MUSE musique en ligne myopera nodejs npm NT NTEventLogger onglet openstack osgi paas package parameters parent php politique prosyst prototype proxies proxy quartz radio rappel recherche regex repository resize RIA rock route ruby rubygems s8500 samsung scheduler scm sel selenium Serializer server shared shell slf4j smartphone so société song spy ssh ssl struct swagger swig tâches téléphone téléréalité test thunderbird timeout token Tomcat tooltip tooltips truststore ubuntu unit test validator virgin virtualbox wave waze web WebApp wiki wikimedia wikipédia wikipen windows yahoo youtube yum