Automated Builds And UI Testing in SharePoint 2010 Development
-
Upload
chris-obrien -
Category
Documents
-
view
5.944 -
download
0
description
Transcript of Automated Builds And UI Testing in SharePoint 2010 Development
BEST PRACTICES CONFERENCE SHAREPOINT
Clarity. Direction. Confidence.
AUTOMATED BUILDS AND UI TESTING IN
SP2010 DEVELOPMENT
Chris O’Brien
DEV203
BEST PRACTICES CONFERENCE SHAREPOINT
About me
Independent SharePoint consultant
Blog: www.sharepointnutsandbolts.com
Twitter: @ChrisO_Brien
Book: Real World SharePoint 2010 (20 MVPs)
LinkedIn: http://uk.linkedin.com/in/chrisobrienmvp
BEST PRACTICES CONFERENCE SHAREPOINT
Problems in SP2010 dev projects
Many dependenciesCode, Features, timer jobs
Deployment is complexe.g. No native support for WSP rollback
Difficult to unit testStill not much traction in SharePoint world?
BEST PRACTICES CONFERENCE SHAREPOINT
Problems in *large* SP2010 dev projects
TrackingHard to keep track of deployments/fixes
Many developers = many deployments?
InefficiencyDevs keeping environment up-to-date
Inconsistent builds (or buildmaster bottleneck)Silly mistakes e.g.
Incorrect versions
Debug vs. Release mode
Testing of actual WSPs
Communication
BEST PRACTICES CONFERENCE SHAREPOINT
Solution recipe
Auto-compile of assemblies and build of WSPsCorrect versions in source control
Add a label in source control to help rollback
Auto incrementing assembly version numberBetter tracking of deployments/fixes etc.
Deployment of WSPs to remote SharePoint 2010 environment
Test environment, not developer machine
UI testingBuild fails on UI test failure
Developer notifications
BEST PRACTICES CONFERENCE SHAREPOINT
Solution ingredients
TFS Team Build workflow (.Net 4.0)Specifies sequence of steps
PowerShellDeploys WSPs, other deployment steps e.g. teardown/setup site
PowerShell remoting (preferred over PsExec)
Allows PS on SharePoint box to be called from build server
Invoke-Command -ComputerName “foo” { script }
Skills• “Good enough”
PowerShell
• “Good enough” workflow (3.5 OK)
BEST PRACTICES CONFERENCE SHAREPOINT
AUTOMATING THE BUILD
BEST PRACTICES CONFERENCE SHAREPOINT
Build definition
Styles:
What’s the trigger?Manual, Scheduled (e.g. nightly), every check-in, Rolling builds, Gated Check-In etc.
Customise workflowMandatory for SharePoint builds
Several workflows OOTBDefaultTemplate, LabTemplate
“Rebuild everything” Suits pre-live
“Build current sprint against production state”
Suits post-live
BEST PRACTICES CONFERENCE SHAREPOINT
Clarity. Direction. Confidence.
DEMOAutomating the build
BEST PRACTICES CONFERENCE SHAREPOINT
Image: selecting build trigger
BEST PRACTICES CONFERENCE SHAREPOINT
Image: customizing build workflow
BEST PRACTICES CONFERENCE SHAREPOINT
CODED UI TESTS
BEST PRACTICES CONFERENCE SHAREPOINT
What is a coded UI test?
Recorded on test agent desktopSupport: browser (inc. AJAX), Silverlight, WPF, forms apps
Generate code which can be modified (e.g. to pass data)
Point and click to add assertionsE.g. navigate to web part gallery, check web part present
BEST PRACTICES CONFERENCE SHAREPOINT
Clarity. Direction. Confidence.
DEMOTesting SharePoint with coded UI tests
BEST PRACTICES CONFERENCE SHAREPOINT
Image: recording a UI test
BEST PRACTICES CONFERENCE SHAREPOINT
ADDING CODED UI TESTS TO THE BUILD
BEST PRACTICES CONFERENCE SHAREPOINT
Integrating coded UI tests into build
Automatic if test assembly name matches filespecDefault = “*test*” somewhere in assembly name
Background:All tests can be run from command-line with MSTest.exe (Unit tests, Coded UI tests, Load tests, Etc.)
Team Build ships with MSTest WF activity (wrapper)
The OOTB workflows contain this activity
Caveat:OOTB workflows must be edited to deploy WSPs and/or run coded UI tests
BEST PRACTICES CONFERENCE SHAREPOINT
Clarity. Direction. Confidence.
DEMOCatching code issues with build/test
process
BEST PRACTICES CONFERENCE SHAREPOINT
Image: build summary
BEST PRACTICES CONFERENCE SHAREPOINT
Image: test results for build
BEST PRACTICES CONFERENCE SHAREPOINT
Image: analyzing failed test (1)
BEST PRACTICES CONFERENCE SHAREPOINT
Image: analyzing failed test (2)
BEST PRACTICES CONFERENCE SHAREPOINT
Why stop at UI testing?
Code profiling
Code analysis Unit tests
SPDispose Check IntelliTrace Load tests
(maybe!)
Test recordings
Collecting system/event
log data
BEST PRACTICES CONFERENCE SHAREPOINT
Image: code profiling in build (1)
BEST PRACTICES CONFERENCE SHAREPOINT
Image: code profiling in build (2)
BEST PRACTICES CONFERENCE SHAREPOINT
Image: IntelliTrace in build
BEST PRACTICES CONFERENCE SHAREPOINT
Best practices
Start on day 0 of projectRetro-fitting can be expensive
Get fast feedback - have a lightweight/quick build run on check-in
Compile all projects/build WSPs
Suggestion - every SharePoint project should do this much
Increment assembly versions (FileVersion) with label generated by build
Leverage UI testing (with or without automated builds)
BEST PRACTICES CONFERENCE SHAREPOINT
Resources
Setting up TFS to build SharePoint Projects - http://bit.ly/9lEqnP
Assembly versions in build workflow - http://bit.ly/eRPB0e
Running tests as part of a build - http://bit.ly/i41eze
PS remoting and SharePoint 2010 - http://bit.ly/9Cb4tF
Also on my blog soon:My customized workflow and PS scripts
Multi-part article series on automated builds/testing
www.sharepointnutsandbolts.com
BEST PRACTICES CONFERENCE SHAREPOINT
Clarity. Direction. Confidence.
THANK YOU!
BEST PRACTICES CONFERENCE SHAREPOINT
Clarity. Direction. Confidence.
APPENDIX SLIDES
BEST PRACTICES CONFERENCE SHAREPOINT
What you need - software
Automated builds = TFS 2010 (Team Build)Server + 1 CAL free with every MSDN level
Need CAL for every user who interacts
Components: Build Controller, Build Agent
Coded UI tests = Visual Studio 2010 Premium/Ultimate (OR ‘Test Elements’ add-on)
Components: Test Controller, Test Agent
BEST PRACTICES CONFERENCE SHAREPOINT
What you need - hardware
Disadvantages:Risk to source control
Performance
SP2010 + TFS2010 = big resource reqs
Bottom line:Don’t do this with prod source control!
Option 1 – the EASY button
BEST PRACTICES CONFERENCE SHAREPOINT
What you need - hardwareOption 2 – a sample topology
BEST PRACTICES CONFERENCE SHAREPOINT
PowerShell remoting
To enable:
To run:Invoke-Command -ComputerName “foo” { script }
Task PS command/Action
Allow remote connections Enable-PSRemoting
Raise memory limit (e.g. for WSP cmds)
Set-Item WSMan:\localhost\Shell\MaxMemory PerShellMB 1000
Allow users from other domain Set registry key
Enable CredSSP authentication http://bit.ly/9Cb4tF