CSC/ECE 517 Fall 2009/wiki1b 4 mv: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(100 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Problem Statement== 
=Introduction=
<blockquote>We have focused mainly on unit tests in this course. But functional and integration testing are also important. How does one write good functional and integration tests? Are there any kinds of tests beyond unit, functional, and integration that one should implement to gain confidence that one's code is correct?
Unit Testing is given a lot of importance in Software Testing. But functional and integration testing are essential too. Hence Functional and Integration Testing is discussed here. This page provides an introduction to these testing methods; also including the good practices to write functional and integration tests. Later additional types of Software Tests are mentioned, which could  be used to gain further confidence that one's code is correct.
</blockquote>


=Functional Testing=
Functional testing is the process of testing of all the functions of a system, ensuring that the system conforms to the user requirements and specifications. It is sometimes referred to as black-box testing, as it does not require understanding of the internal structure of the implementation.


==Different stages of Software Testing==
Functional testing can be done by using manual or automated methods[http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_4_mv#References]. In both the methods, a series of tests have to be run marking the interaction between the user and the system, ensuring that the system performs as it was supposed to. Since Use cases mainly depict the interaction between the user and system, functional test suites are created from requirement use cases, with each scenario becoming a functional test[http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_4_mv#References].  
http://www.aptest.com/testtypes.html (either use reference to this place or type in our own words)


==Functional Test Plan==
"The functional test plan measures the quality of the functional components of the system[http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_4_mv#References]". The test plan is written by the <i>Author</i>. The <i>Author</i> lists a number of test cases, containing the input, expected results, and pre and post-test setup. After a module is unit tested, the <i>Tester</i> executes the functional test cases and records the actual results. The <i>Reviewer</i> compares the Actual results with the expected results and reports whether each test case passed or failed the test.
==Guidelines to write good Functional Tests==
# The test plan must be written by persons who have extensive knowledge of the business requirements. It is advisable that the developers do not write the test plans. This is because developers tend to unknowingly write test cases whose functionality is based on the implementation rather than the initial functional specifications.
# The functional test plans should be created as early as possible, probably as soon as the functional specifications are ready.
# The functional test plan should be updated when there are changes in the business requirements.
# For each functionality, a list of test cases should be defined so that each aspect of the functionality is covered.
# The <i>Author</i> should clearly include the pre-test setup for the test cases so that the <i>Tester</i> can easily execute the test cases.
# Usually the same test cases are run a number of times. Hence after executing a test case, any data added to the system should be cleared so as to not affect further tests or rerunning of the same test case. Hence the <i>Author</i> should also give post-test setup details.
# As a module is built and unit tested, the <i>Tester</i> should execute the particular test cases and record the results.
# <i>Reviewer</i> should review the results and report any bugs to the developers.


==Functional Testing==  
==Examples==
Testing software based on its functional requirements. It ensures that the program physically works the way it was intended and all required menu options are present. It also ensures that the program conforms to the industry standards relevant to that environment; for example, in a Windows program, pressing F1 brings up help.
Examples of pre-test setup, test cases and post-test setup are given below. The complete reference for the example can be found at [http://www.developer.com/java/ent/article.php/3623476/Functional-Test-Plans-The-Right-Way.htm Functional Test Plans]
[http://msdn.microsoft.com/en-us/library/aa292128%28VS.71%29.aspx]
<strong>DEFINITION:</strong> <i>Testing of all features and functions of a system [software, hardware, etc.] to ensure requirements and specifications are met.</i>


Use cases are generally developed from the user specifications. These use cases are useful in providing the guidelines for functional testing.
The pre-test setup for Test Case: <i>Create new user profile</i> can be given as:
      [UserName: "A": --> username:    "A"]
      [UserName: "A": --> first name:  "John"]
      [UserName: "A": --> last name:    "Smith"]
      [UserName: "A": --> access level: "read-only"]
      [UserName: "A": --> password:    "profile1"]


==Prerequisites before Functional Testing==
The test cases for the function:<i>Verify that only valid users can access the system</i> can be given as:  
# Build Functional test cases from uses cases, with each use case scenario becoming a functional test.
# As a module is built and unit tested apply the particular test case.
# Prioritize the test cases.
# it should be geared towards a non-technical audience. Therefore, references to underlying programming languages must not be present in the final document
# The author of the functional test plan must be a person who has in-depth knowledge of the business requirements. It is preferable that application developers do not compose functional test plans. The reason behind such an approach is simple: The developer's interpretation of the requirements might differ from those of the person who initially created them.


<table cellspacing="2" width=900 border="1" align="center" >
<tr valign="top" bgcolor="#99ffff">
<th>Test Case #</th>
<th>Required Input</th>
<th>Expected Results</th>
<th>Results</th>


<th>Pass/Fail</th></tr>


==Integration Testing==
<tr valign="top"><td colspan="5">
<ul>
<li>Verify that only valid users can access the system.</li>
<li>Verify that valid users cannot access the system without entering a valid password.</li>
</ul></td></tr>
 
<tr valign="top"><td>1</td>
<td>Navigate to the login screen</td>
<td>Login screen with release number A is loaded.</td>
 
<td>&nbsp;</td>
<td>&nbsp;</td></tr>
 
<tr valign="top"><td>2</td>
<td>Enter user name "INVALIDUSER", password "INVALIDUSER", and click on login button</td>
<td>Error message:<br>
"User name is not found"</td>
<td>&nbsp;</td>
<td>&nbsp;</td></tr>
 
<tr valign="top"><td>3</td>
<td>Enter user name for user <b>&#91;UserName: "A":--&gt; username&#93;</b> and password "test"</td>
 
<td>Error Message:<br>
"Password for user <b>&#91;UserName: "A": --&gt; username&#93;</b> is invalid"</td>
<td>&nbsp;</td>
<td>&nbsp;</td></tr>
 
<tr valign="top"><td>4</td>
<td>Enter user name <b>&#91;UserName: "A": --&gt; username&#93;</b> and password <b>&#91;UserName: "A": --&gt; password&#93;</b></td>
 
<td>The main page is loaded with a message:<br>
"Welcome <b>&#91;UserName: "A": --&gt; first name&#93; &#91;UserName: "A": --&gt; last name&#93;</b></td>
<td>&nbsp;</td>
<td>&nbsp;</td></tr>
</table>
 
The post-test setup for the above scenario can be given as:
      Remove [UserName: "A": --> username: "A"] from the LDAP Server.
 
Another Example of Test Cases can be found at [http://math-cs.gordon.edu/courses/cs211/ATMExample/InitialFunctionalTests.html Initial Functional Test Cases for an ATM system]
 
=Integration Testing=
Integration Testing is a process of testing the application on the whole. After going through the unit testing of the modules, these modules need to be integrated, and during this process things may go wrong, Integration process is the phase wherein these errors are captured and rectified.
Integration Testing is a process of testing the application on the whole. After going through the unit testing of the modules, these modules need to be integrated, and during this process things may go wrong, Integration process is the phase wherein these errors are captured and rectified.
It is very common for modules after having successful passed all the unit test cases to fail when they are integrated with other modules. Integration testing is an important phase and sometimes there are separate teams which handle integration testing.  
It is very common for modules after having successful passed all the unit test cases to fail when they are integrated with other modules. Integration testing is an important phase and sometimes there are separate teams which handle integration testing.  
 
<br/>
<strong>DEFINITION:</strong><i>Integration testing is a systematic technique for constructing the program structure while at the same time conducting tests to uncover errors associated with interfacing. The objective is to take unit tested components
<strong>DEFINITION:</strong><i>Integration testing is a systematic technique for constructing the program structure while at the same time conducting tests to uncover errors associated with interfacing. The objective is to take unit tested components
and build a program structure that has been dictated by design.</i>
and build a program structure that has been dictated by design.</i>[http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_4_mv#References]


==Integration Test approaches==
==Integration Test approaches==  
Integration testing can be done in a variety of ways
Integration testing can be done in a variety of ways [[Image:TopDown_Approach.jpg|thumb|Top Down Approach]]
# Top-Down Approach. In this approach the modules higher up in the control hierarchy are integrated first and low-level modules are added later. The advantage of this approach is that the modules with high level logic are tested first and hence bugs in the crucial logic are caught early. Further this approach does not require drivers to be written. Although a number of stubs have to be written and managed [[Image:TopDown_Approach.jpg|thumb|Top Down Approach]]
# '''Top-Down Approach.''' In this approach the modules higher up in the control hierarchy are integrated first and low-level modules are added later. The advantage of this approach is that the modules with high level logic are tested first and hence bugs in the crucial logic are caught early. Further this approach does not require drivers (dummy control modules used instead of the actual modules for the purpose of testing) to be written. Although a number of [http://en.wikipedia.org/wiki/Test_stubs stubs] have to be written and managed  
# Bottom Up Approach. In this approach, the low level modules are integrated first and high level logic is tested late. While integrating the low level modules, the control modules are replaced by dummy modules called as drivers. Thus driver codes have to be written and managed while using this approach. [[Image:BottomUp_Approach.jpg|thumb|Bottom Up Approach]]
# '''Bottom Up Approach.''' In this approach, the low level modules are integrated first and high level logic is tested late. While integrating the low level modules, the control modules are replaced by dummy modules called as drivers. Thus driver codes have to be written and managed while using this approach. [[Image:BottomUp_Approach.jpg|thumb|Bottom Up Approach]]  
 
# '''Umbrella approach.''' Another approach is called the umbrella approach. It is a hybrid of the top down and the botom up approach, ie both the bottom up and top down approaches are used.In this approach we first test along the functional and control flow paths, for this we use the bottom up approach. The results thus gathered are later integrated in a top down manner. This kind of testing allows creating early prototypes of the system with has limited functionality thereby helping is the creations of the product in an incremental manner. This types of testing also minimizes the use of [http://en.wikipedia.org/wiki/Test_stubs stubs] and drivers which are needed in the top-down and bottom up approaches.
# Umbrella approach. Another approach is called the umbrella approach. It is a hybrid of the top down and the botom up approach, ie both the bottom up and top down approaches are used.In this approach we first test along the functional and control flow paths, for this we use the bottom up approach. The results thus gathered are later integrated in a top down manner. This kind of testing allows creating early prototypes of the system with has limited functionality thereby helping is the creations of the product in an incremental manner. This types of testing also minimizes the use of stubs and drivers which are needed in the top-down and bottom up approaches.
 


==Prerequisites before Integration Testing==
==Prerequisites before Integration Testing==
The system that is being tested, all of its modules should be rigorously tested as a component, i.e they should have gone through unit tests.
The system that is being tested, all of its modules should be rigorously tested as a component, i.e they should have gone through unit tests.
 
==Steps to write good Integration Test Cases==
==Steps in writing good Integration Test Cases==
 
#Create a Test Plan
#Create a Test Plan
#Create test cases and the sample data against which they would be tested.
#Create test cases and the sample data against which they would be tested.
Line 51: Line 106:
#Retest the code.
#Retest the code.


==How To write Good Integration Test Cases and do effective Integration Testing==
==How To write good Integration Test Cases and do effective Integration Testing==
The main focus of integration testing is that it needs to check whether the different components are working smoothly and are interacting with each other in the proper manner. The Integration test cases specifically focus on the flow of data/information/control from one component to the other.
The main focus of integration testing is that it needs to check whether the different components are working smoothly and are interacting with each other in the proper manner. The Integration test cases specifically focus on the flow of data/information/control from one component to the other.
A few thing that needs to be kept in mind for effective integration testing are
A few thing that needs to be kept in mind for effective integration testing are
Line 58: Line 113:
# Log all the errors that have been found and document them with the solutions as well as the version number so that we could keep track of which build was being tested when the error was discovered.
# Log all the errors that have been found and document them with the solutions as well as the version number so that we could keep track of which build was being tested when the error was discovered.


==Examples==
Sample Integration test case Templates can be found at [http://it.toolbox.com/blogs/enterprise-solutions/deliverable-integration-test-cases-29932 Integration test cases]
Integration test plan Templates can be found at [http://geekswithblogs.net/dthakur/articles/10430.aspx Integration test plans]


=Beyond Functional and Integration Testing=
[[Image:TestPhase.jpg|thumb|Test Phases]]
Integration and Functional testing are not the only testing that are done for checking the validity of the system. Other test cases includes:<br/>
'''Unit Testing:''' This is the first stage where the developer tests the component he/she is creating. More can be found at [http://en.wikipedia.org/wiki/Unit_testing Unit Testing]<br/>
'''Validation Testing:''' After integration Testing, validation testing takes place wherein checks are made to ensure that the functional requirements are satisfied.<br/>
'''Alpha and Beta Testing:'''When the product about to be released, it is first exposed to some end users who test the application. This is alpha beta testing. More can be found at [http://www.majordojo.com/uploads/AlphaBetaTesting.pdf Alpha and Beta Testing]<br/>
'''Recovery Testing:''' In this phase the system is made to crash and is used to check to see if it recovers in the proper manner. More can be found at [http://en.wikipedia.org/wiki/Recovery_testing Recovery Testing]<br/>
'''Security Testing:''' Systems that store and record sensitive information need to be protected from threats, in this phase the systems protection mechanisms are tested. More can be found at [http://en.wikipedia.org/wiki/Security_testing Security Testing]<br/>
'''Stress Testing:'''The system is overloaded with data and it is checked to whether it crashes. More can be found at [http://en.wikipedia.org/wiki/Stress_testing Stress Testing] <br />
'''Performance Testing:''' It tests the run time performance of software within the context of the system. More can be found at [http://en.wikipedia.org/wiki/Performance_testing Performance Testing]<br/>
'''Smoke Testing:'''  smoke testing is a preliminary to further testing, which should reveal simple failures severe enough to reject a prospective software release. More can be found at [http://en.wikipedia.org/wiki/Smoke_test Smoke Test]<br/>
'''Acceptance Testing:''' acceptance testing performed by the customer is known as user acceptance testing (UAT). This is also known as end-user testing, site (acceptance) testing, or field (acceptance) testing. More can be found at [http://en.wikipedia.org/wiki/Acceptance_testing Acceptance Testing]


=References=


Functional Tests:
# [http://www.segue.com/pdf/automated_functional_testing.pdf Automated Functional Testing]
Functioanl Test usually check whether the code is running according to what the user/client needs.  
# [http://searchsoftwarequality.techtarget.com/generic/0,295582,sid92_gci1303938,00.html# Functional Tests to ensure Software Quality]
# [http://www.developer.com/tech/article.php/3623476/Functional-Test-Plans-The-Right-Way.htm Functional Test Plans]
# Software Engineering: A Practitioner's Approach by Roger S. Pressman ISBN 0073655783


http://www.davenicolette.net/articles/ftdd.pdf
=External Links=
# [http://math-cs.gordon.edu/courses/cs211/ATMExample/InitialFunctionalTests.html Initial Functional Test Cases for an ATM system]
# [http://it.toolbox.com/blogs/enterprise-solutions/deliverable-integration-test-cases-29932 Integration test cases]
# [http://geekswithblogs.net/dthakur/articles/10430.aspx Integration test plans]
# [http://en.wikipedia.org/wiki/Unit_testing Unit Testing]
# [http://www.majordojo.com/uploads/AlphaBetaTesting.pdf Alpha Beta Testing]
# [http://en.wikipedia.org/wiki/Recovery_testing Recovery Testing]
# [http://en.wikipedia.org/wiki/Security_testing Security Testing]
# [http://en.wikipedia.org/wiki/Stress_testing Stress Testing]
# [http://en.wikipedia.org/wiki/Performance_testing Performance Testing]
# [http://en.wikipedia.org/wiki/Smoke_test Smoke Test]
# [http://en.wikipedia.org/wiki/Acceptance_testing Acceptance Testing]

Latest revision as of 23:31, 28 September 2009

Introduction

Unit Testing is given a lot of importance in Software Testing. But functional and integration testing are essential too. Hence Functional and Integration Testing is discussed here. This page provides an introduction to these testing methods; also including the good practices to write functional and integration tests. Later additional types of Software Tests are mentioned, which could be used to gain further confidence that one's code is correct.

Functional Testing

Functional testing is the process of testing of all the functions of a system, ensuring that the system conforms to the user requirements and specifications. It is sometimes referred to as black-box testing, as it does not require understanding of the internal structure of the implementation.

Functional testing can be done by using manual or automated methods[1]. In both the methods, a series of tests have to be run marking the interaction between the user and the system, ensuring that the system performs as it was supposed to. Since Use cases mainly depict the interaction between the user and system, functional test suites are created from requirement use cases, with each scenario becoming a functional test[2].

Functional Test Plan

"The functional test plan measures the quality of the functional components of the system[3]". The test plan is written by the Author. The Author lists a number of test cases, containing the input, expected results, and pre and post-test setup. After a module is unit tested, the Tester executes the functional test cases and records the actual results. The Reviewer compares the Actual results with the expected results and reports whether each test case passed or failed the test.

Guidelines to write good Functional Tests

  1. The test plan must be written by persons who have extensive knowledge of the business requirements. It is advisable that the developers do not write the test plans. This is because developers tend to unknowingly write test cases whose functionality is based on the implementation rather than the initial functional specifications.
  2. The functional test plans should be created as early as possible, probably as soon as the functional specifications are ready.
  3. The functional test plan should be updated when there are changes in the business requirements.
  4. For each functionality, a list of test cases should be defined so that each aspect of the functionality is covered.
  5. The Author should clearly include the pre-test setup for the test cases so that the Tester can easily execute the test cases.
  6. Usually the same test cases are run a number of times. Hence after executing a test case, any data added to the system should be cleared so as to not affect further tests or rerunning of the same test case. Hence the Author should also give post-test setup details.
  7. As a module is built and unit tested, the Tester should execute the particular test cases and record the results.
  8. Reviewer should review the results and report any bugs to the developers.

Examples

Examples of pre-test setup, test cases and post-test setup are given below. The complete reference for the example can be found at Functional Test Plans

The pre-test setup for Test Case: Create new user profile can be given as:

      [UserName: "A": --> username:     "A"]
      [UserName: "A": --> first name:   "John"]
      [UserName: "A": --> last name:    "Smith"]
      [UserName: "A": --> access level: "read-only"]
      [UserName: "A": --> password:     "profile1"]

The test cases for the function:Verify that only valid users can access the system can be given as:

Test Case # Required Input Expected Results Results Pass/Fail
  • Verify that only valid users can access the system.
  • Verify that valid users cannot access the system without entering a valid password.
1 Navigate to the login screen Login screen with release number A is loaded.    
2 Enter user name "INVALIDUSER", password "INVALIDUSER", and click on login button Error message:
"User name is not found"
   
3 Enter user name for user [UserName: "A":--> username] and password "test" Error Message:
"Password for user [UserName: "A": --> username] is invalid"
   
4 Enter user name [UserName: "A": --> username] and password [UserName: "A": --> password] The main page is loaded with a message:
"Welcome [UserName: "A": --> first name] [UserName: "A": --> last name]
   

The post-test setup for the above scenario can be given as:

      Remove [UserName: "A": --> username: "A"] from the LDAP Server.

Another Example of Test Cases can be found at Initial Functional Test Cases for an ATM system

Integration Testing

Integration Testing is a process of testing the application on the whole. After going through the unit testing of the modules, these modules need to be integrated, and during this process things may go wrong, Integration process is the phase wherein these errors are captured and rectified. It is very common for modules after having successful passed all the unit test cases to fail when they are integrated with other modules. Integration testing is an important phase and sometimes there are separate teams which handle integration testing.
DEFINITION:Integration testing is a systematic technique for constructing the program structure while at the same time conducting tests to uncover errors associated with interfacing. The objective is to take unit tested components and build a program structure that has been dictated by design.[4]

Integration Test approaches

Integration testing can be done in a variety of ways

Top Down Approach
  1. Top-Down Approach. In this approach the modules higher up in the control hierarchy are integrated first and low-level modules are added later. The advantage of this approach is that the modules with high level logic are tested first and hence bugs in the crucial logic are caught early. Further this approach does not require drivers (dummy control modules used instead of the actual modules for the purpose of testing) to be written. Although a number of stubs have to be written and managed
  2. Bottom Up Approach. In this approach, the low level modules are integrated first and high level logic is tested late. While integrating the low level modules, the control modules are replaced by dummy modules called as drivers. Thus driver codes have to be written and managed while using this approach.
    Bottom Up Approach
  3. Umbrella approach. Another approach is called the umbrella approach. It is a hybrid of the top down and the botom up approach, ie both the bottom up and top down approaches are used.In this approach we first test along the functional and control flow paths, for this we use the bottom up approach. The results thus gathered are later integrated in a top down manner. This kind of testing allows creating early prototypes of the system with has limited functionality thereby helping is the creations of the product in an incremental manner. This types of testing also minimizes the use of stubs and drivers which are needed in the top-down and bottom up approaches.

Prerequisites before Integration Testing

The system that is being tested, all of its modules should be rigorously tested as a component, i.e they should have gone through unit tests.

Steps to write good Integration Test Cases

  1. Create a Test Plan
  2. Create test cases and the sample data against which they would be tested.
  3. If automated tools are being used, scripts should be created.
  4. After the components have been integrated, start executing the test cases created in point 2.
  5. Log the bugs found and rectify the same.
  6. Retest the code.

How To write good Integration Test Cases and do effective Integration Testing

The main focus of integration testing is that it needs to check whether the different components are working smoothly and are interacting with each other in the proper manner. The Integration test cases specifically focus on the flow of data/information/control from one component to the other. A few thing that needs to be kept in mind for effective integration testing are

  1. Ensure that the correct versions of the components are integrated together.
  2. Automate the integration of components so that there is lesser chance for human error.
  3. Log all the errors that have been found and document them with the solutions as well as the version number so that we could keep track of which build was being tested when the error was discovered.

Examples

Sample Integration test case Templates can be found at Integration test cases

Integration test plan Templates can be found at Integration test plans

Beyond Functional and Integration Testing

Test Phases

Integration and Functional testing are not the only testing that are done for checking the validity of the system. Other test cases includes:
Unit Testing: This is the first stage where the developer tests the component he/she is creating. More can be found at Unit Testing
Validation Testing: After integration Testing, validation testing takes place wherein checks are made to ensure that the functional requirements are satisfied.
Alpha and Beta Testing:When the product about to be released, it is first exposed to some end users who test the application. This is alpha beta testing. More can be found at Alpha and Beta Testing
Recovery Testing: In this phase the system is made to crash and is used to check to see if it recovers in the proper manner. More can be found at Recovery Testing
Security Testing: Systems that store and record sensitive information need to be protected from threats, in this phase the systems protection mechanisms are tested. More can be found at Security Testing
Stress Testing:The system is overloaded with data and it is checked to whether it crashes. More can be found at Stress Testing
Performance Testing: It tests the run time performance of software within the context of the system. More can be found at Performance Testing
Smoke Testing: smoke testing is a preliminary to further testing, which should reveal simple failures severe enough to reject a prospective software release. More can be found at Smoke Test
Acceptance Testing: acceptance testing performed by the customer is known as user acceptance testing (UAT). This is also known as end-user testing, site (acceptance) testing, or field (acceptance) testing. More can be found at Acceptance Testing

References

  1. Automated Functional Testing
  2. Functional Tests to ensure Software Quality
  3. Functional Test Plans
  4. Software Engineering: A Practitioner's Approach by Roger S. Pressman ISBN 0073655783

External Links

  1. Initial Functional Test Cases for an ATM system
  2. Integration test cases
  3. Integration test plans
  4. Unit Testing
  5. Alpha Beta Testing
  6. Recovery Testing
  7. Security Testing
  8. Stress Testing
  9. Performance Testing
  10. Smoke Test
  11. Acceptance Testing