Upload
allan-mangune
View
187
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
Agile ToolsAllan Spartacus Mangune
Delivery
• Lectures and demos – 3 hours
• 3 case studies and hands-on exercises – 1 hour each
Agenda
Test-driven Development & Unit Testing
Version Control & Continuous Integration Testing
Web Performance & Load Testing
Test-driven Development
Similar to test-first
practice in Extreme
Programming
Designed for
product
development with
short iterations
Write failing test
code for desired
functionality
Write code to past
the test
Refactor code to
desired coding
standard
Development Cycle
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Write A Test
Write a failing unit test for each new
functionality
• The test must cover the requirements and how
exceptions are handled in the software product
Developer must have a correct
understanding of the functionality
• Refer to use case, domain models and details of the user
story
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Run All Tests
Ensures that the test harness is working
and the new unit test actually fails
• Pending the writing of correct program code
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Write Some Code
Based on the new functionality to be
developed, write the program code
The objective is to code enough to pass the
unit test
• Any duplicate code at this point must be refactored later
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Run Test
Run the test to verify that the written code passes
the test unit test
• If the test fails, review the code against specific requirements
and test cases and make the necessary modification
• Re-run the test
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Refactor
When the code is passing the test, refactor to the
desired standard
• Code follows coding standard
• No duplicate code
• Make design changes to improve the overall maintainability
of the system
Rerun all the tests after refactoring
• To ensure that all tests are passing
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Repeat
Repeat the cycle.
• Write a new unit test for a new functionality
Each cycle should be very short
• Few code edits and less that an hour
• A long cycle may prompt the developer to resort to
debugging
Write a test
Run all tests
Write some
codeRun test
Refactor
Repeat
Test Structure
Arrange
• Setup and initialize the desired state prior to testing
Act
• Execute the test against the method being tested
Assert
• Determines the outcome of the test
[TestClass]public class HomeControllerTest{
[TestMethod]public void Index(){
// ArrangeHomeController controller = new
HomeController();
// ActViewResult result = controller.Index() as
ViewResult;
// AssertAssert.IsNotNull(result);
}….
}
Fakes and Mocks
Isolate code
• Controls what is failing and where it is happening
Replaces other parts of the system with stubs and shims
• Stub - A class replacement with the same interface
• Shim – Used to replace the actual method call with the fake ones
Visual Studio Unit Test Explorer
Unit Test Explorer
Create and run a unit test
Isolating Code Under Test with Microsoft Fakes
Create and Run Unit Test (1)
Create a test
project
Create a test
class
Create a test
method against a
functionality
Run test
Create and Run Unit Test (2)
Create a test
project
Create a test
class
Create a test
method against a
functionality
Run test
Arrange, Act, Assert
Arrange
• Define the test input
Act
• Run the method under test
Assert
• Verify the result
Demo: Visual Studio Unit Test Explorer
Case Study & Hands-on Exercises
Version Control
Management of changes to source files
Each change is marked with change set or revision number
• A revision is made to one or more source files
A change set is usually accompanied by a unique ID, timestamp, and the name of the person who
committed the revision
Changes to one or more source files can be reverted to specific version
Continuous Integration Testing
Continuous integration is a process wherein the development team continuously integrate their source files to a version control system
• Allows the team to work on the latest version of the software
• Delays due to late integration are avoided
Use an automated build system to continuously run automated integration tests
• Breaking changes are uncovered and fixed
• Rules can be implemented to prevent source files that break the build from committed to the version control system
Source FilesVersion Control Server
Automated Build Server
Build is broken
Team Foundation Server Version Control
Team Foundation Server Version Control (TFSVC)
Manage multiple revisions to source files
• Check-ins
• Branching and merging
• Shelving
Contributor
• Check out files
• Check in modified or new files
• Delete source files
• Compare source files
• Merge changes between files
How to Use TFSVC?
Set up development workspace
Create the version control of your app’s solution files
Create a new solution under version control
Put an existing solution to the version control
Contribute source files
Isolate risks by branching from trunk
Resolve version control conflicts
Set up Development Workspace
Access the Team Explorer in
Visual Studio
• Connect to a Team’s project
Map the team’s project to a
local folder
• Developer’s PC
Map the workspace to get
the project’s source files
Create the Version Control
Access the Source Control Explorer and
create the main trunkCheck in files to the main trunk
Create a New Solution Under Version Control
Create a new project Add the project to a version control
Put an Existing Solution to the Version Control
Open your solutionAccess the solution’s property page
and add the solution to TFSVC
Contribute source files (changes)
Access the pending
changes in solution or
project
Relate change set to one
or more work items
Check in the pending
changes. Adding
comment helps
Branching
Manage simultaneous work of different teams
from the same code base
Merge changes from a branch to the main
trunk
Resolve Version Control Conflicts
Conflicts are highlighted
when checking in pending
changes
Access the Resolve Conflicts
link
Resolve conflicts by keeping
local version, server version
or merge conflicts
Demo: Team Foundation Server Version Control
Continuous Integration Testing with TFS Build Service
Using the Build Service for Continuous Integration Testing
Create or edit a build definition
On Build triggers, set continuous integration
Create or Edit Build Definition
Access the Builds tab
from Team Explorer
Create a new build
or edit a new one
Set the build
definitions
Continuous Integration Trigger
Access the Trigger tab Select Continuous Integration
Gated Check-in
offers a stricter
check in policy
Demo: Continuous Integration Testing with TFS Build Service
Case Study & Hands-on Exercises
Web Performance and Load Testing
Web Performance and Load Testing
Record web performance tests
Add a load test
Run load test
Analyze test results
Web Performance Test
Create a web performance and load test project
Record a web performance test
Load Test (1)
Create a load test
Choose a load pattern
Add a test mix
Plug the web performance
test
Run the load test
Analyze the results of the
test
Load Test (2)
Create a load test
Choose a load pattern
Add a test mix
Plug the web performance
test
Run the load test
Analyze the results of the
test
Demo: Web Performance and Load Testing
Case Study & Hands-on Exercises
ReferencesTest-driven development - http://en.wikipedia.org/wiki/Test-driven_development
http://en.wikipedia.org/wiki/Continuous_integration
http://en.wikipedia.org/wiki/Extreme_programming_practices#Continuous_integration
Use Team Foundation Version Control - http://msdn.microsoft.com/en-us/library/ms181237(v=vs.120).aspx
Unit Test - http://msdn.microsoft.com/en-us/library/dd264975.aspx
Build Service - http://msdn.microsoft.com/en-us/library/ms181709.aspx
Performance and load testing - http://msdn.microsoft.com/en-us/library/dn250793.aspx
Copyright (C) 2014. Allan Spartacus Mangune
This work is licensed under a Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International License.
License URL: http://creativecommons.org/licenses/by-nc-
sa/4.0/