Tuesday 16 October 2012

Mobile testing tools latest update

I have been working in mobile testing close to 5 years and there are different tools that have gone past me.
Latetly I have used Robotium / Eggplant and tried Calabash / Fonemonkey(http://www.gorillalogic.com/) / Monkey runner and couple more.

Mobile Apps testing (not web related testing)
Robotium has given me pretty good results with testing of mobile apps, It can interact very well with apps and can be configured to run with Jenkins build server (other tools also can do that).
Its a very powerful open source tool and has been updated frequently so new functionalities are introduced and errors are correct pretty fast.

Mobile Web testing
Selenium Android driver and Selenium Iphone driver are the unchallenged masters for webtesting.The way Robotium works is pretty similar to selenium but the apps that can be tested is the real difference.
For anyone who has used selenium and has basic knowledge about testing mobile phones it must be a cake walk

Try gorilla logic if you want a record and play back solution 

Calabash is BDD focused tool and is available for both Android and Iphone , I have installed and tried it for learning purpose. haven't got it running for Real project.
I am pretty impressed with tool as such.

Eggplant is more of UI based tool and as per my experience its the only best tool available for Android / IOS / Symbian / Blackberry phones. There are loads of problems when it comes to connectivity but for limited set of repeated testcases it yeilds quick results. Sense talk used in Eggplant iss easy to learn.You definitely dont need to have programming knowledge to run the testcases.


Please leave compliments if like my blog or leave comments

(Selenium webdriver + Ant + Testng) Build.xml sample file to be used

I have got this build.xml from one of the sites...
and have customised it a bit to get it working.


${basedir} refers to project directory

I have updated path to suite.xml file in below code
I have also added below code to remove existing test output and create each one every time tests are run.

<target name="runTests" depends="compile"> <echo message="${basedir}"/>
<delete dir="${basedir}/test-output"/>
<mkdir dir="${basedir}/test-output"/> 
 <testng classpath="${test.classpath}:${build.dir}"> <xmlfileset dir="${basedir}/src/testpackage/" includes="suite1.xml"/> </testng> </target>

 

<
project name="Automation"
default="clean" basedir=".">
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="browser" value="/home/nxavier/Downloads/firefox/firefox"/>
<target name="setClassPath">
<path id="classpath_jars">
<pathelement path="${basedir}/" />
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
</target>
<target name="loadTestNG" depends="setClassPath">
<taskdef resource="testngtasks" classpath="${test.classpath}"/>
</target>
<target name="init">
<mkdir dir="${build.dir}"/>
<tstamp>
<format property="timestamp" pattern="dd-MM-yyyy_(HH-mm-ss)"/>
</tstamp>
<property name="build.log.dir" location="${basedir}/buildlogs"/>
<mkdir dir="${build.log.dir}"/>
<property name="build.log.filename" value="build_${timestamp}.log"/>
<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
<echo message="build logged to ${build.log.filename}"/>
</target>
<target name="clean">
<echo message="deleting existing build directory"/>
<delete dir="${build.dir}"/>
</target>
<target name="compile" depends="clean,init,setClassPath,loadTestNG">
<echo message="classpath:${test.classpath}"/>
<echo message="compiling.........."/>
<javac destdir="${build.dir}" srcdir="${src.dir}" includeantruntime="false" classpath="${test.classpath}"/>
</target>
<target name="runTests" depends="compile">
<echo message="${basedir}"/>
<delete dir="${basedir}/test-output"/>
<mkdir dir="${basedir}/test-output"/>
<testng classpath="${test.classpath}:${build.dir}">
<xmlfileset dir="${basedir}/src/testpackage/" includes="suite1.xml"/>
</testng>
</target>
<target name="report" depends="runTests">
<delete dir="${basedir}/testng-xslt"/>
<mkdir dir="${basedir}/testng-xslt"/>
<xslt in="${basedir}/test-output/testng-results.xml"
style="${basedir}/src/xslt/testng-results.xsl" out="${basedir}/testng-xslt/index.html" processor="SaxonLiaison">
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir"/>
<param expression="true" name="testNGXslt.sortTestCaseLinks"/>
<param expression="FAIL,SKIP,PASS,BY_CLASS" name="testNgXslt.testDetailsFilter"/>
<param expression="true" name="testNgXslt.showRuntimeTotals"/>
<classpath refid="classpath_jars"/>
</xslt>
</target>
<target name="RunAndViewReport" depends="report">
<exec executable="${browser}" spawn="yes">
<arg line="'${basedir}/testng-xslt/index.html'" />
</exec>
</target>
<target name="sendMail" depends="RunAndViewReport">
<zip destfile="${basedir}/testng-xslt/Report.zip" basedir="${basedir}/testng-xslt"/>
<mail mailhost="smtp.gmail.com" mailport="465" subject="Notification of TESTNG build" ssl="false" user="tester@gmail.com" password="password">
<from address="tester@gmail.com"/>
<to address="tester@gmail.com"/>
<message>The build has finished. A details report of this build is aatched</message>
<attachments>
<fileset dir="testng-xslt">
<include name="**/*.zip"/>
</fileset>
</attachments>
</mail>
</target></
project>

Suite.xml must be written as per testng guidelines.
I haven't verified email functionality

I will make another post explaining how to use this build xml and run it from command line

Saturday 6 October 2012

Selenium - Create CONFIG file and read it (java)

One of the challenges we face while creating test suite is to put common settings into a file and read it from code as and when neccessary. I did struggle a bit so thought sharing this might help any one who encounters similar problem.

Steps:

1) Create a file say in ur src folder or create a new package config and put a file called config.properties
2) From the file where you want to read create a varaiable like

public
static Properties CONFIG = new Properties();
3) Then load the content into it from the file you have created

FileInputStream fn = new
FileInputStream("path to project"+ \\src\\configure\\config.properties);

CONFIG
.load(fn);

4) Put a value into file config.properties which has to be read 
ex:
#url
mainsite=http://www.rediff.com

5) To read value from file
CONFIG
.getProperty("mainsite");
Some more system properties can be read from system as well
ex: System.getproperty("user.dir") for project


Wil share a sample code some time later but the above steps should help.

Friday 5 October 2012

Resolving GIT problem in Eclipse



I installed GIT on my machine all of a sudden my eclipse was dead slow.
I had to over come this problem without unistalling git
After playing with preference found a solution atlast


Windows >Preferences -> Team -> GIT  and uncheck these boxes  as in the above picture