Pages

Monday, October 6, 2014

Test Management with TestLink

TestLink is a great open-source tool to manage test cases. It helps to organize all the testcases, version control and the testing process. It can be integrated with any bugtracking tool (mantis, bugzilla… etc). Also, TestLink can be use to see if all requirements are covered with testcases. and it provides varies kind of test reports too. Before working with TestLink, let’s have some knowledge about the test case.

What is in a test case?
Testcase describes action and reaction of a feature in a software product. In one hand, test case document can be use as a breakdown of requirement document. On the other hand, it can be use to estimate testing effort. Testcase document contains these fields.
Test Case ID, Test Case Title, Test Case Summary, Precondition, Step actions, Expected Result, Actual Result, Inputs, Status(Pass/Fail)

This is a template of a test case document.


Install TestLink


Just like Mantis, You can install TestLink with five easy steps (in a windows server). For more details, Check the installation manual locate at <testlinkfolder>\docs\testlink_installation_manual.pdf.

1)
 Install xampp or wamp (apache, mysql, PHP package) -http://www.wampserver.com/en/

2) Download the latest stable version of TestLink - http://sourceforge.net/projects/testlink/files/

      3) Extract mantis to wamp project location (example - C:\wamp\www\)

4) In config.inc.php  file, change
                        log directory ($tlCfg->log_path) edit the path to C:\wamp\www\testlink\logs
                        upload directory ($g_repositoryPath) to C:\wamp\www\testlink\upload_area

5) Browse the project from your web browser (example -http://<ip>/Testlink) and follow the installation instructions.

Note : Default credentials to login testlink are, user: admin; password: admin

Excel to TestLink
Now, the most important part! Before you start working with TestLink, I recommend you to create a test case document in a excel sheet. Have a look at my sample test case document – (click here to download). Your testcase document need to be exactly same format.


Important! – Look at the steps and expected result numbering system. Don’t use 1) 2) ... instead of 1. 2. ...  that will cause errors.

TestLink only understand XML format of the testcase document. So, now you need a tool to convert your excel testcase document to XML format. Click here to download the XMLConverter. Double click the “Exceml.exe” file inside the “XMLConvert\Debug” folder. Browse and locate the excel testcase document and “Convert to Xml”. You will find the converted file inside “Xml” folder. Now you are ready to upload testcases to TestLink.

Work with TestLink
  1. Create a Project – First you need to create a project. Go to the “Test Project Management” section to create a project. 

  2. Select the Project – Make sure you are currently selecting the correct project. 

  3. Create Test Plan – Use “Test Plan Management” to create a test plan.

  4. Create a Test Build/Release - Specify the Build of the Project you are going to test.

  5. Import Test Cases for the project. - Now you need to import your testcase XML file from test specification. 

  6. Add test cases to the Test Plan – In "Test Plan Content" section, click “Add / Remove Test Cases” to add selected testcases to the test plan. 

  7. Assign Test Cases to Test Engineers. 

  8. Test case execution. 

  9. See Reports and Charts. 
Tip: You can integrate TestLink with your bug tracking tool. Click “Issue Tracker Management“ under “system” and set configurations. Make sure to assign and activate the bug tracker when you creating projects.
{ Read More }


Wednesday, October 1, 2014

Behavior Driven Development with Cucumber

While searching a better automation solution for web applications, I could find a great automation framework which is called “Cucumber”. Simply, Cucumber is a BDD supported testing tool that executes automated tests. It is easy & flexible solution that supports java-selenium development. Unlike selenium robot framework, this BBD solution has a huge technical support on internet.

What is BDD?
BDD (Behavior Driven Development) is a good extension to the conventional TDD (Test Driven Development).


TDD is widely using by developers to write their unit tests. Add a test, run entire test suit and write some code on newly added test, rerun all tests and refactor is the main concept of TDD.

BDD has a different approach. Its mainly focus on the behavior (input and outcome) of the functionality. In other words, BDD is a combination of user story (a short introduction of tests) and acceptance criteria.


Example :
          As a [role] I want [feature] so that [benefit]
          Given [initial context]
          When [input event]
          Then [outcome]

Cucumber is used to execute tests written in this format. The language that Cucumber understands is called 'Gherkin'. Gherkin is just a combination of four keywords (given, when, then, and). It's very easy to write tests with Gherkin. also, even non-technical people can understand the tests and scenarios. Check below example which is a test written in Gherkin.

Feature: Search on Google
  As an user
  I want to search on Google
  So that I can see results

  Scenario: results are shown
    Given the page is open "http://www.google.com"
    When I search for "Cucumber"
    Then a browser title should contains "Cucumber"

Now, let’s have some fun with cucumber!

Setup your first cucumber project
  1. Download sample cucumber-java-selenium project from here - https://github.com/michalvich/cucumber-jvm-selenium-example

    Note 1 : Check the directory structure. You can see ‘pom.xml’ in the root directory of the project. ‘pom.xml’ is the fundamental unit of work in Maven. It is contains information about the project and configuration details used by Maven to build the project. 
  2. Note 2 : You can see the .feature file at '..\src\test\resources\com\michalvich\cucumber\selenium\example'. That is the cucumber test case document which is written in Gherkin.
    Note 3 : 
    You can see java code at '..\src\test\java\com\michalvich\cucumber\selenium\example', which is the code we should write to execute our cucumber test cases.


  3. Install Java, create a user variable “JAVA_HOME” and set it to jdk installation directory (example - C:\Program Files\Java\jdk1.7.0_21)

  4. update/create the Path environment variable in the user variables and append the %JAVA_HOME%\bin

  5. Check java is installed successfully. ( type “java –version” in command prompt)

  6. Download eclipse IDE (https://www.eclipse.org/downloads/)

  7. Download maven (http://maven.apache.org/download.cgi)

  8. Read the installation instruction at http://maven.apache.org/download.cgi#Installation or follow these steps.

    1. Add the M2_HOME environment variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.2.1
    2. Add the M2 environment variable in the user variables with the value %M2_HOME%\bin
    3. update/create the Path environment variable in the user variables and append the value %M2% 

  9. Check maven is installed successfully. (type “mvn –version” in command prompt)

  10. Note : Make this small change before proceed. Open the 'pom.xml' file. find this set of codes
    <dependency>
           <groupId>org.seleniumhq.selenium</groupId>
           <artifactId>selenium-java</artifactId>
           <version>2.28.0</version>
    </dependency>
    Change the version no "2.28.0" to "2.41.0"

  11. Go to the place which pom.xml located and type,
    1.  “> mvn package” (to build the project)
    2. “> mvn install” (optional)
    3. “> mvn eclipse:eclipse” (to generate the eclipse project files from your POM)

  12. Open eclipse and set the maven repo directory (in eclipse - windows - preferences - java - built path -> add M2_REPO --- maven repo directory (C:/Users/Test/.m2/repository))

  13. Open eclipse and import the project ( file – import – general - existing project in to workspace)

  14. Run the project as a junit (run – run configurations – browse the project and the class)
How to write your own code?
  • First, write a cucumber test case document, save as a .feature and put it in the same directory which locate ‘GoogleSearch.feature’.
  • Then, Create a empty java class with the same name and just run it. You can see the code snippets print in your eclipse console window.
  • Finally, Copy and paste the snippets to implement missing steps. Write few lines of codes for test. you can have any help from internet.

Look! How easy it is! Software automation is not a nightmare anymore!
{ Read More }


Blogger news

Blogroll

What's Hot