Ordina SOFTC Presentation - Delivering quality software with TFS 2010

773 views

Published on

Ordina's Stand out from the Crowd event of May 26th - the presentation, see them all on Slideshare Ordina Belgium

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
773
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Maken layer diagramToevoegen dependenciesValidaties runnen(Wisselen pijl van richting tss domain model & repositories)Tonen dat systeem nieuw diagram kan genereren met ‘correct’ beeldToon ook de architecture explorer en een aantal controles die je hier kan doenGenereer een diagram op class levelPas analyzers toe:Circular ReferencesFind HubsUnused nodes
  • http://mikefourie.wordpress.com/2010/05/09/visual-studio-database-edition-2010-%E2%80%93-static-code-analysis-review-part-1/http://msdn.microsoft.com/en-us/library/bb381703(v=vs.80).aspxGa naar test projectBeschrijven 4 soorten database tests:Database unit testing is not limited merely to testing the database's programmability objects. You might want to author the four classes of tests that this section describes.Feature TestsThe first and likely most prevalent class of database unit test is a feature test. In my mind, feature tests test the core features—or APIs, if you will—of your database from the database consumer's perspective. Testing a database's programmability objects is the mainline scenario here. So, testing all the stored procedures, functions, and triggers inside your database constitute feature tests in my mind. To test a stored procedure, you would execute the stored procedure and verify that either the expected results were returned or the appropriate behavior occurred. However, you can test more than just these types of objects. You can imagine wanting to ensure that a view, for example, return the appropriate calculation from a computed column. As you can see, the possibilities in this realm are large.Schema TestsOne of the most critical aspects of a database is its schema, and testing to ensure that it behaves as expected is another important class of database unit tests. Here, you will often want to ensure that a view returns the expected set of columns of the appropriate data type in the appropriate order. You might want to ensure that your database does, in fact, contain the 1,000 tables that you expect.Security TestsIn today's day and age, the security of the data that is stored within the database is critical. Thus, another important class of database unit tests are those that test the database security. Here, you will want to ensure that particular users exist in your database and that they are assigned the appropriate permissions. You will often want to create negative tests that attempt to retrieve data from restricted tables or views and ensure that the access is appropriately denied.Stock-Data TestsMany databases contain stock data, or seed data. This data changes infrequently and is often used as lookup data for applications or end users. ZIP codes and their associated cities and states are great examples of this kind of data. Therefore, it is useful to create tests to ensure that your stock data does, in fact, exist in your database.Set Database Test Configuration Aanmaken stock-data testUitleggen Raiserror command voor teruggeven errorsEXEC [dbo].[Ingredient Names]IF (@@ROWCOUNT <> 5) RAISERROR('Ingredient Names did not return 5 rows',11,1)Doe daarnahetzelfde maar dan met een test conditionTest ConditionsTeam Edition for Database Professionals, however, does not stop there in terms of test verification. Clearly, users would need a set of commonly performed verification tasks, and the product should offer a better way of performing these. Thus was born the concept of UI-based client-side test conditions that verify the results of your test after the SQL has been executed. You set and configure these conditions inside the Database Unit Test Designer.Team Edition for Database Professionals includes the test conditions that appear in Table 1.Table 1. Available test conditionsTest conditionDescriptionRow Count Condition fails if ResultSet does not contain expected row count. You can use this condition to do light verification that ensures that the number of rows that you expected was returned in the resultset. Scalar Value Condition fails if scalar value in ResultSet does not equal the value that you expected. You can use this condition for deeper verification that ensures that actual values in the returned resultset equal what you expected. Empty Resultset Condition fails if the ResultSet is not empty. Not Empty Resultset Condition fails if the ResultSet is empty. Execution Time Condition fails if the test takes more time than you expected to complete. This duration is the time that it takes to execute the SQL against the server using the ADO.NET provider. Inconclusive Condition always leads to an inconclusive result. This condition is added by default to a test. It is useful to have this condition added by default so that, when you run the test, you know that you have not yet completed working on the test. The condition is a marker for work that remains to be doneKorte intro van database project functionaliteitOpenen sp_RealBadCodeIs stored procedure vol bad practicesGa dan naar Data  Static Code Analysis  ConfigureBeschrijven rulesUitvoeren validatie
  • http://blogs.msdn.com/b/zainnab/archive/2011/05/10/code-metrics-calculating-metrics.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zainnab+%28Visual+Studio+Tips+and+Tricks%29http://msdn.microsoft.com/en-us/library/bb385914.aspx http://stylecop.codeplex.com/documentationStatic Code Analysis-------------------------------Toevoegen code file met sql injectionTonen rule set configuratieKiezen Security Rule SetRunnen analysisUitleggen dat je nu gemakkelijk de lijst met rules kan manipuleren en delenCode Metrics-------------------------------Runnen code metrics op 1 projectUitleggen wat de verschillende metrics betekenenhttp://blogs.msdn.com/b/zainnab/archive/2011/05/10/code-metrics-calculating-metrics.aspx Maintainability Index – Calculates an index value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability. Color coded ratings can be used to quickly identify trouble spots in your code. A green rating is between 20 and 100 and indicates that the code has good maintainability. A yellow rating is between 10 and 19 and indicates that the code is moderately maintainable. A red rating is a rating between 0 and 9 and indicates low maintainability.Cyclomatic Complexity – Measures the structural complexity of the code. It is created by calculating the number of different code paths in the flow of the program. A program that has complex control flow will require more tests to achieve good code coverage and will be less maintainable.Depth of Inheritance – Indicates the number of class definitions that extend to the root of the class hierarchy. The deeper the hierarchy the more difficult it might be to understand where particular methods and fields are defined or/and redefined.Class Coupling – Measures the coupling to unique classes through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration. Good software design dictates that types and methods should have high cohesion and low coupling. High coupling indicates a design that is difficult to reuse and maintain because of its many interdependencies on other types.Lines of Code – Indicates the approximate number of lines in the code. The count is based on the IL code and is therefore not the exact number of lines in the source code file. A very high count might indicate that a type or method is trying to do too much work and should be split up. It might also indicate that the type or method might be hard to maintain.IMPORTANT: code metrics ignore generated code!!!StyleCop-------------------------------http://www.dotnetspark.com/kb/500-c-sharp-code-reviews-using-stylecop.aspx Show StyleCop settingsRun it on Silverlight project(let’s check how bad Gill’s code is :-)Show info in output windowShow info in warning windowGo to error SA1503, SA1402Ndepend------------------------------Run analysis on projectExplain some of the resultsShow default cql queriesShow how to write your own cql queriesShow assembly compare between versions
  • This is the new build log. The build failed even though the unit test passed.Architecture validation is now part of the build process.A class in one layer is calling another class in another layer.The build process is telling us not good, unacceptable.
  • http://mikefourie.wordpress.com/2010/05/09/visual-studio-database-edition-2010-%E2%80%93-static-code-analysis-review-part-1/http://geekswithblogs.net/jakob/archive/2011/01/30/integrating-code-metrics-in-tfs-2010-build.aspxhttp://blogs.blackmarble.co.uk/blogs/rfennell/archive/2011/04/22/how-to-use-the-tfs-2010-community-stylecop-build-activity.aspxOpen build definitionEnable code analysisOpen testsettings file, select a ruleset, enable analysisEnable architecture validationAdd the following MSBuild argument: /p:ValidateArchitecture=trueShow code metrics power tool(http://www.microsoft.com/downloads/en/details.aspx?FamilyID=edd1dfb0-b9fe-4e90-b6a6-5ed6f6f6e615)Explain that it is installed on the build serverShow custom activityShow thresholds in build definitionChange the value and run a buildShow style cop custom activitityShow results
  • Ordina SOFTC Presentation - Delivering quality software with TFS 2010

    1. 1.
    2. 2. Delivering quality software with TFS 2010<br />Bart Wullems (bart.wullems@ordina.be)<br />
    3. 3. .NET Architect<br />ALM Specialist<br />Competence Center Leader Software Efficiency<br />Microsoft Certified Trainer<br />Microsoft Certified Professional<br />Blog<br />http://bartwullems.blogspot.com<br />Email<br />bart.wullems@ordina.be<br />
    4. 4. Agenda<br />Quality gates<br />Architecture validation<br />Layer validation<br />Database validation<br />Database Unit Tests<br />Database Rule Validation<br />Code validation<br />Stylecop<br />FXCop<br />NDepend<br />Build Server Integration<br />
    5. 5. How can we improve software quality?<br />5<br />
    6. 6. More testing?<br />6<br />
    7. 7. More code reviews?<br />7<br />
    8. 8. The bodyguard Pattern<br />Protecting your code from all evil…<br />8<br />
    9. 9. Quality Gates<br />9<br />
    10. 10. Too common a scenario<br />
    11. 11. What we should aim for<br />
    12. 12. How does Visual Studio 2010 help?<br />Automate the process<br />Build Server<br />Lab Management<br />Enforces the process<br />Check-in policy<br />Gated check-in<br />Continuous Integrations<br />Lets you know when you’re “Done”<br />Test reports <br />Project data reports<br />
    13. 13. Feature Quality Gates<br />
    14. 14. Feature Quality Gates<br />
    15. 15. Architecture Validation<br />15<br />
    16. 16. Layer diagram<br />Architecturalvalidationensures code matches intended design <br />Layer diagram details the intended design<br />Classes and namespaces are mapped to layers in the diagram<br />
    17. 17. Demo<br />17<br />
    18. 18. Database Validation<br />18<br />
    19. 19. Database Unit Testing<br />Ensures that database changes do not break existing code<br />Generate automated tests for programmability objects<br />Develop a series of tests to run with every database build<br />Design and customize your tests in the language of your choice<br />T-SQL, Visual Basic.NET/C#<br />Builds on existing Team Test unit testing functionality<br />Integrate your database tests along side your application unit tests<br />
    20. 20. Database code analysis<br />Very similar to performing static analysis to detect and correct defects in managed code. <br />Analysis rules are configurable<br />Useful for identifying <br />Transact-SQL Design Issues<br />Transact-SQL Naming Issues<br />Transact-SQL Performance Issues<br />20<br />
    21. 21. Demo<br />21<br />
    22. 22. CODE Validation<br />22<br />
    23. 23. Unit Testing with Code Coverage<br />
    24. 24. Code Analysis Tools<br />Visual Studio Static Code Analysis<br />Analyzes code against a rules database including coding standards, best practices, and defects<br />Integrated into Visual Studio<br />Works on compiled DLL<br />Create your own rules<br />Code Metrics<br />Measure quality through code metrics<br />StyleCop<br />Analyzes C# source code to enforce a set of style and consistency rules. <br />Complementary to Visual Studio Code Analysis<br />Run from inside of Visual Studio or integrated into MSBuild<br />Works on source code <br />Create your own rules<br />Ndepend<br />Displays API differences between two assemblies<br />Measure quality through code metrics<br />Enforce standard and custom rules<br />Powerful code query language<br />
    25. 25. Code Metrics<br />
    26. 26. Demo<br />26<br />
    27. 27. Build Integration<br />27<br />
    28. 28. Bringing it all together<br />28<br />
    29. 29. Architecture validation during build<br />
    30. 30. Demo<br />30<br />
    31. 31.
    32. 32. Follow Ordina…<br />Share your thoughts via #SOFTC <br />Follow us on twitter: @OrdinaBE<br />Find the presentationsonwww.slideshare.net/ordinaBe<br />Be informed atwww.linkedin.com/company/ordina-belgium<br />

    ×