Lab Manual: Army Institute of Technology
Lab Manual: Army Institute of Technology
LAB MANUAL
i
List of Experiments
(As given by SPPU)
(Software Testing & Quality Assurance-Elective II)
Sr. Page
Title
No No
Mini Project-1 01
Create a small application by selecting relevant system environment /
platform and programming languages. Narrate concise Test Plan consisting
features to be tested and bug taxonomy. Prepare Test Cases inclusive of Test
1
Procedures for identified Test Scenarios. Perform selective Black-box and
White-box testing covering Unit and Integration test by using suitable
Testing tools. Prepare Test Reports based on Test Pass/Fail Criteria
and judge the acceptance of application developed.
Mini Project-2 04
Create a small web-based application by selecting relevant
system environment / platform and programming languages. Narrate concise
2 Test Plan consisting features to be tested and bug taxonomy. Narrate scripts
in order to perform regression tests. Identify the bugs using Selenium
WebDriver and IDE and generate test reports encompassing exploratory
testing
ii
Lab Practice-II Mr. Hule Kuldeep
7. Outcomes:
You are able to understand Unit and Integration testing with Tool with Test Report.
8. Theory Concepts:
What is Unit Testing?
Unit Testing of software applications is done during the development (coding) of an application.
The objective of Unit Testing is to isolate a section of code and verify its correctness. In procedural
programming a unit may be an individual function or procedure
The goal of Unit Testing is to isolate each part of the program and show that the individual parts are
correct. Unit Testing is usually performed by the developer.
Unit Testing Tools
There are several automated tools available to assist with unit testing. We will provide a few examples
below:
a) Jtest: Parasoft Jtest is an IDE plugin that leverages open-source frameworks (Junit, Mockito,
PowerMock, and Spring) with guided and easy one-click actions for creating, scaling, and
maintaining unit tests. By automating these time-consuming aspects of unit testing, it frees
the developer to focus on business logic and create more meaningful test suites.
b) Junit: Junit is a free to use testing tool used for Java programming language. It provides
assertions to identify test method. This tool test data first and then inserted in the piece of code.
c) NUnit: NUnit is widely used unit-testing framework use for all .net languages. It is open source
tool which allows writing scripts manually. It supports data-driven tests which can run in parallel.
d) JMockit: JMockit is open source Unit testing tool. It is code coverage tool with line and path
metrics. It allows mocking API with recording and verification syntax. This tool offers Line
coverage, Path Coverage, and Data Coverage.
e) EMMA: EMMA is an open-source toolkit for analyzing and reporting code written in Java
language. Emma support coverage types like method, line, basic block. It is Java-based so it is
without external library dependencies and can access to the source code.
f) PHPUnit: PHPUnit is a unit testing tool for PHP programmer. It takes small portions of code
which is called units and test each of them separately. The tool also allows developers to use pre-
define assertion methods to assert that system behave in a certain manner.
Those are just a few of the available unit testing tools. There are lots more, especially for C
languages and Java, but you are sure to find a unit testing tool for your programming needs regardless of
the language you use.
Extreme Programming & Unit Testing
Unit testing in Extreme Programming involves the extensive use of testing frameworks. A unit test
framework is used in order to create automated unit tests. Unit testing frameworks are not unique to
extreme programming, but they are essential to it. Below we look at some of what extreme programming
brings to the world of unit testing:
Tests are written before the code
Rely heavily on testing frameworks
All classes in the applications are tested
Quick and easy integration is made possible
Bug taxonomy
Bug taxonomies help in providing fast and effective feedback so that they can easily identify
possible reasons for failure of the software. Using bug taxonomy, a large number of potential bugs can
be grouped into few categories.
Whenever a new bug is reported, using bug taxonomy, a tester can easily analyse and put that bug into
any of these categories.
At the end of testing, Testers can understand the type of categories of bugs that frequently occurred and
thereby in successive rounds of testing he can focus on writing more test cases that would help to detect
such bugs. In addition, test leaders can guide their testers to focus on such frequently occurring bugs.
The summary of the Bug Taxonomy is given below,
Requirements, Features, and Functionality Bugs
Structural Bugs
Data Bugs
Coding Bugs
Interface, Integration, and System Bugs
Test and Test Design Bugs
Testing and Design Style
What is Integration Testing?
In integration Testing, individual software modules are integrated logically and tested as a group. A
typical software project consists of multiple software modules, coded by different programmers.
integration Testing focuses on checking data communication amongst these modules. Hence it is also
termed as 'I & T' (Integration and Testing), 'String Testing' and sometimes 'Thread Testing Integration
Test Case:
Integration Test Case differs from other test cases in the sense it focuses mainly on the interfaces &
flow of data/information between the modules. Here priority is to be given for the integrating
links rather than the unit functions which are already tested.
Sample Integration Test Cases for the following scenario: Application has 3 modules say 'Login Page',
'Mail box' and 'Delete mails' and each of them are integrated logically.
Here do not concentrate much on the Login Page testing as it's already been done in Unit Testing. But
check how it's linked to the Mail Box Page.
Similarly Mail Box: Check its integration to the Delete Mails Module.
Test
Test Case Objective Test Case Description Expected Result
Case
ID
Check the interface link between the Enter login credentials and click To be directed to the
1
Login and Mailbox module on the Login button Mail Box
Selected email
Check the interface link between the From Mail box select the email
2 should appear in the
Mailbox and Delete Mails Module and click delete button
Deleted / Trash folder
4. Give JunitTestProject name to the project and check use project folder as root for source and
class files
9. See the Programming hub package see in project Explorer Screen of Eclipse
10. Right Click on Programminghub Package->New->Class give the name JunitClass->Click Finish.
12. Write a small program with only two functions Add and Multiplication
14. Name test suite as AddTest and choose New Junit4 test
18. Write a code for Test case addition of two number inside AddTest
19. Let us run AddTest test case. Right click AddTest-> Debug As->JUnit Test
20. Result of test case is as follows. It shows 0 error and 0 failure and green color test bar which
means that test case has run successfully (Green Color Bar Indicate)
21. Let us purposely give wrong input in assertEquals method or unexpected result here we write 501
instead of 500 indicate wrong addition result
22. Now test case should fail. (Brown Color Bar Indicate) So again run AddTest as follows
23. Similarly you can Create Test case for Multiplication Function
Click on Project Explorer Screen-> Right Click on JunitClass->New->JUnit Test Case-> Give name
MulTest.
24. Click on Next ->Select Mul Check Box -> Click Finish
10. Test Suite – it is used to test multiple test cases at one time.
1. Now let us create Test Suite both add and mul test cases in one time
3. Click on Finsh
4. Next Screen Appear that automatically create Test Suite for Add and Mul
6. Test Suite Executed successfully Test suite fails even if a single test case among all fails.
4. Select Check Box Create Simple Project-> Click Next-> Give Group Id and Artifact name
10. after Enter keyword Junit inside Seach box then Enter->it shown another Site Maven Repository for
Junit Select that site.
12. Click on JUnit-> Open and click on latest version as shown below (here 4.12x)
15. Now Paste the above code in between <dependencies> tag then save pom.xml file
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
22. Now go to Eclipse -> Click on Maven Test Project->Right Click on src/test/java
25. It shows the manvenTest Package under src/test/java folder now rename same by right click on
mavenTest Click on Refactor->Rename->give another name com.tem.mavenDemo->Click on ok
28. after Download->go to Program File->create one folder give name maven-> now extract the
downloaded file in maven folder
2. Set Path of Add M2_HOME and MAVEN_HOME Create new system variable name M2_HOME
and MAVEN_HOME separately set variable value-> C:\Program Files\maven
To run test suite or all test cases under project, give command mvn test
Enter E:\MavenTestProject>mvn test
This Command is Used to See the Test Report
You can even run individual test cases.
Give command mvn test –Dtesttestcasename
Eg. mvn test –Dtest-AllTest
14. Conclusion
In this way using JUnit and Maven Automation tool we are Perform Unit Testing and
Prepare Test Report of same.
15. Assignment Question
a) Write any Five Tool for White Box and Black Box Testing Purpose.
2.8.5 How to Choose the Right Selenium Tool for Your Need
Tool Why Choose?
To learn about concepts on automated testing and Selenium, including:
Selenium IDE Selenese commands such as type, open, clickAndWait, assert, verify, etc.
Locators such as id, name, xpath, css selector, etc.
Executing customized JavaScript code using runScript
Exporting test cases in various formats.
To create tests with little or no prior knowledge in programming.
Selenium RC To create simple test cases and test suites that you can export later to RC or
WebDriver.
To test a web application against Firefox only.
To design a test using a more expressive language than Selenese
To run your test against different browsers (except HtmlUnit) on different
operating systems.
To deploy your tests across multiple environments using Selenium Grid.
To test your application against a new browser that supports JavaScript.
To test web applications with complex AJAX-based scenarios.
To use a certain programming language in designing your test case.
WebDriver To test applications that are rich in AJAX-based functionalities.
To execute tests on the HtmlUnit browser.
To create customized test results.
To run your Selenium RC scripts in multiple browsers and operating systems
Selenium Grid simultaneously.
To run a huge test suite, that needs to complete in the soonest time possible.
5. Now Open Eclipse IDE-----> Create Java Project---->Right Click Project Name->Properties->
Java Build Path-->Libraries-->Add External JAR--->add selenium-server-standalone-3.13.0 jar--
->Apply and Close.
6. Now Want Open the chrome browser with facebook.com page via Selenium Web driver
Java Coding so here we need to write Java Code in Class file which we already created
8. Right click on java program, select Run As and > "Java Application". After Code Successfully
Run now see the output in Console Prompt
8. After Execution Code Mouthshut.java Chrome Browser Opened Automatically with Specified
website you can also see the output of rating in console as well as file you created.
In This way, you can Collect all different kind of colleges, hospital rating and review from various
website like mouthshout.com, Justdial.com via Selenium Web driver Tool
Selenium IDE:
1. Download Selenium IDE Chrome Extension from following Link
https://chrome.google.com/webstore/detail/selenium-
ide/mooikfkahbdckldjjndioackbalphokd?hl=en
2. Click on Add to Chrome
3. Check the icon on of IDE Square in right side after browser after successfully installation to
chrome
4. Now Click on record button do some operation on website…see the report in console of IDE
command target and value….in this way you also find out xpath etc information.
5. You can also check the Automated Test Case Pass or Fails see the following figure
Experiment No.1
1. Title: Test Case Generation
2. Aim: Identify the test cases & make them in standard format of test cases.
3. Objectives:
Students will conduct a formal conversion with probable users.
Students prepared requirement specification document.
Students have to create different test cases based on collected requirements.
4. Outcomes:
To understand what is a specialized users & what problems they face.
To capture functional & data specific Test cases.
To create different test cases based on collected data.
5. Software/Hardware/Other Requirements:
Core 2 duo/i3/i5/i7 - 64bit processor
Operating System – ubuntu/Fedora 64bit OS
MS-Word, Excel or SmartDraw
Questionnaires (Not Compulsory)
Reference SRS
6. Theory:
A. What is a Test Case?
A test case template is a document that comes under one of the test artifacts, which
allows testers to develop the test cases for a particular test scenario in order to verify
whether the features of an application are working as intended or not.
Test cases are the set of positive and negative executable steps of a test scenario
which has a set of pre-conditions, test data, expected results, post-conditions, and
actual results.
Most of the companies are using test case management tools such as Quality Center
(HP QC), JIRA, etc., and some of the companies still using excel sheets to write test
cases.
B. What is the difference between Test Scenario vs Test Case?
Test Scenario: Test Scenario gives the idea of what we have to test. Test Scenario is
like a high-level test case.
For example: Verify the login functionality of the Gmail account.
Also read Test Scenario vs Test Case
Assume we need to write test cases for a scenario (Verify the login of the Gmail
account).
Here are some test cases.
a) Enter valid User Name and valid Password
b) Enter valid User Name and invalid Password
c) Enter invalid User Name and valid Password
d) Enter invalid User Name and invalid Password
7. Procedure:
Follow the below steps to write the test cases.
Step 1 – Test Case ID:
Each test case should be represented by a unique ID. It’s good practice to follow some
naming convention for better understanding and discrimination purposes.
Step 2 – Test Case Description:
Pick test cases properly from the test scenarios
Example: Test scenario: Verify the login of Gmail
Test case: Enter a valid username and valid password
Step 3 – Pre-Conditions:
Conditions that need to meet before executing the test case. Mention if any
preconditions are available.
Example: Need a valid Gmail account to do login
Step 4 – Test Steps:
To execute test cases, you need to perform some actions. So, write proper test steps.
Mention all the test steps in detail and in the order how it could be executed from the
end-user’s perspective.
Example: Enter Username
Enter Password
Click Login button
Step 5 – Test Data:
You need proper test data to execute the test steps. So, gather appropriate test data.
The data which could be used an input for the test cases.
Example: Username: [email protected]
Password: STM
10. References:
a) M G Limaye, “Software Testing Principles, Techniques and Tools”, Tata McGraw
Hill, ISBN: 9780070139909 0070139903
b) https://www.softwaretestingmaterial.com/test-case-template-with-explanation/