Ad

Showing posts with label Software - Testing. Show all posts
Showing posts with label Software - Testing. Show all posts

Tuesday, July 24, 2012

Testing your javascript with BDD

It seems like nowadays people that write javascript just hack the heck out the code and produce reams of code without testing it properly. I went about to try and correct my evil past ways and try and drive out my code with some behavior driven design. I used the Jasmine framework to write my tests which provides a nice GUI to see your tests running. This is what Jasmine framework is describes as:
Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.
All you need to do it download the standalone version and cull out the existing files in 'src' and 'specs' directories (they are just examples), implement your test spec and add the source files to the SpecRunner.html and vwala you have a nice little JS test suite. Jasmine Documentation Reference Example Tutorial

Monday, May 9, 2011

Integrating soap ui maven plugin

What a pleasure, a way to integrate your soap ui project into a maven build :)

Just pop this into your pom.xml from where your web module is located; this will start/stop jetty for the soap ui plugin to invoke its tests:


<plugin>
               <groupId>org.mortbay.jetty</groupId>
               <artifactId>maven-jetty-plugin</artifactId>
               <version>6.1.21</version>
               <configuration>
                   <stopKey>foo</stopKey>
                   <stopPort>9999</stopPort>
                   <webAppConfig>
                       <contextPath>/test</contextPath>
                   </webAppConfig>
               </configuration>
               <executions>
                   <execution>
                       <id>start-jetty</id>
                       <phase>pre-integration-test</phase>
                       <goals>
                           <goal>run</goal>
                       </goals>
                       <configuration>
                           <scanIntervalSeconds>0</scanIntervalSeconds>
                           <daemon>true</daemon>
                       </configuration>
                   </execution>
                   <execution>
                       <id>stop-jetty</id>
                       <phase>post-integration-test</phase>
                       <goals>
                           <goal>stop</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>




And insert the soap ui plugin to invoke on inegration-test phase pointing to a valid soap ui project XML:

<plugin>
                <groupId>eviware</groupId>
                <artifactId>maven-soapui-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <projectFile>${project.basedir}/soapui-project.xml
                    </projectFile>
                    <outputFolder>${project.basedir}/target/test/soapui-results</outputFolder>
                    <junitReport>true</junitReport>
                </configuration>
                <executions>
                    <execution>
                        <id>soapUI</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>