quality assurance of large c++ projects

38
Quality Assurance of Large C++ Projects Anton Naumovich

Upload: corehardby

Post on 03-Mar-2017

1.188 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Quality assurance of large c++ projects

Quality Assurance of Large C++ Projects

Anton Naumovich

Page 2: Quality assurance of large c++ projects

Anton NaumovichEngineering Manager at SolarWindsTechnical Consultant at DPI.SolutionsDeveloper at Microsoft (Hyper-V) in the past

We are doing backup :)

Page 3: Quality assurance of large c++ projects

conference.corehard.by - we host a C++ conference in Minsk every season (3-4 times a year)

Page 4: Quality assurance of large c++ projects

Quality Assurance

Page 5: Quality assurance of large c++ projects

Quality Assurance vs Quality ControlFocus on quality of processes Finding defects in ready product

Proactively preventing defects Reactively identify defects

Page 6: Quality assurance of large c++ projects

Goal of Quality Assurance

Improve development processes so that defects do not arise when the product is being developed

Page 7: Quality assurance of large c++ projects

Relative Effectiveness of Quality Techniques

Quality TechniqueInformal design reviewsFormal design inspections Informal code reviews Formal code inspectionsModeling or prototyping Personal desk-checking of codeUnit testNew function (component) test Integration test Regression test System test Low-volume beta test (<10 sites) High-volume beta test (>1,000 sites)

Average Rate of Found Defects35%55%25%60%65%40%30%30%35%25%40%35%75%

Only combination of techniques can assure 95% and higher quality

Page 8: Quality assurance of large c++ projects

General Principle of Software QualityImproving quality reduces development costs

Page 9: Quality assurance of large c++ projects

Source Control

Page 11: Quality assurance of large c++ projects

Build Tools

Page 12: Quality assurance of large c++ projects

List of build tools for C++

De facto standard for build tools

Package managers are gaining popularity

Page 13: Quality assurance of large c++ projects

Coding Standards

Page 14: Quality assurance of large c++ projects

Importance of Coding Standards

Impossible to build a complex system without standardization

Share experience from the industry and your project

Make code look and behave uniformly

Use only the “safest” subset of the C++ Language

Антон Семенченко. Закон иерархических компенсаций Седова и C++ Co

re Guidelines

Page 15: Quality assurance of large c++ projects

Available Standards and Guidelines for C++C++ Core Guidelines by Bjarne & Co

High Integrity C++ Coding Standard

Google C++ Style Guide

Sutter, Alexandrescu: C++ Coding Standards … and many more

Make your Guidelines extensible. Support by the Dev Team

Enrich your Guidelines as a result of problems retrospective

Page 16: Quality assurance of large c++ projects

Automate guideline checking as a pre-commit hook for the changeset

No unchecked code in the repository!

Automate Guideline Checking

cpplint.py – regex-based tool for Google C++ Style Guide

Guideline Checker Tool – available with VS 2015 for C++ Core Guidelines

★ clang-tidy – clang-based tool for C++ Core Guidelines, Google C++ Style Guide, and your own checks!

Uncrustify, clang-tidy: modernize – source code transformers

Page 17: Quality assurance of large c++ projects

Code Reviews

Page 18: Quality assurance of large c++ projects

Code Review: Best Practices

Integrate review with your issue tracking system

Independent review by 2 people increase ratio of found defects

Prefer pre-commit reviews if possible

Development Review Validataion

Page 19: Quality assurance of large c++ projects

Code Review Systems

Review Board

Gerrit for Git

Crucible by Atlassian

… and many more

Page 20: Quality assurance of large c++ projects

Code Review Checklist

1. Does the code implement requirements spec?

2. Is the code compliant with the Coding Standards?

3. Does the code change any existing functionality?

4. Are all non-success scenarios handled?

5. ...

Page 21: Quality assurance of large c++ projects

Unit Testing

Page 22: Quality assurance of large c++ projects

Unit Testing Ideology

Integrate unit tests into your project build process (as a post-build event)

Aim for 100% coverage

Design code to be testable: Test-Driven Design

Практики надежного модульного тестирования для C++ - Юрий Ефимочев

Page 24: Quality assurance of large c++ projects

Static Code Analysis

Page 25: Quality assurance of large c++ projects

Static Code Analysis: Basics

Your C++ Compiler:

1. Use max warning level and disable checks one-by-one if they are not reasonable

2. Use built-in static analysis checks (e.g. -Weffc++ for gcc)

3. Use several compilers because they have different checks

Run static analysis as a build or pre-commit step

More recommendations on using compilers by Jason Turner

Page 26: Quality assurance of large c++ projects

Static Code Analysis Tools

Cppcheck - free and open-source

PVS Studio

Coverity

Copy-paste detectors (e.g. CPD)

… check out Static Code Analysis Tools for C++

Page 27: Quality assurance of large c++ projects

Code Coverage

Page 28: Quality assurance of large c++ projects

Code Coverage Tools

lcov for *NIX

OpenCPPCoverage for Windows

Use coverage for Unit Test runs and include

coverage report into code review checklist

Page 29: Quality assurance of large c++ projects

IntrusiveRuntime Verifiers

Page 31: Quality assurance of large c++ projects

Non-intrusiveRuntime Verifiers

Page 32: Quality assurance of large c++ projects

Assertive Programming (Programming by contract)

If it can't happen, use assertions to ensure that it won't

Leave assertions turned on in production code(except for when it affects performance)

Collect and analyze assertions

Page 33: Quality assurance of large c++ projects

Crash Dump Reporting/Analysis System

Check out Crash Dump Collection and Analysis System talk

Collect and analyze crash dumps from test labs and from production

Page 34: Quality assurance of large c++ projects

Continuous Integration

Page 35: Quality assurance of large c++ projects

Continuous Integration Tools

TeamCity: 3 agents for free

Jenkins

Team Foundation Server

Page 36: Quality assurance of large c++ projects

Staging Repository

MainlineRepository

StagingRepository

Developer commits

1. Review2. Build bots3. Unit tests4. Static analysis5. Code coverage6. Autotests

Production builds

Merge

Page 37: Quality assurance of large c++ projects

“Free” Lunch