The slides or my talk at SoftShake (soft-shake 2013) about unit test maintenance.
The code can be found here : https://github.com/tsimbalar/UnitTestsMaintenanceHell
Abstract (in French, sorry ...) :
“Oui, les tests unitaires, c’est cool, mais à chaque fois que je fais une petite modification dans le code, je dois réparer tous mes tests, c’est pénible et ça me prend un temps fou! Alors j’hésite à laisser tomber ma suite de tests, ou alors je fais l’impasse sur ce refactoring …”
Vous avez déjà entendu ça, non ? Quand on se met à écrire des tests unitaires (que ce soit avant ou après le code à tester), au début, c’est la galère, puis, peu à peu, avec l’habitude et l’expérience, on les écrit mieux et plus rapidement … mais quand il s’agit de modifier du code existant, on a quand même l’impression de se prendre les pieds dans les tests.
Dans cette session, je vous présenterai quelques techniques, trucs et outils pour écrire des tests plus maintenables et vous sentir moins gênés lors des refactorings du code. Cette présentation se basera sur des exemples de code et des démos (en C# et avec Visual Studio)
Les tests apportent une forte valeur ajoutée à nos projets, ce qu’il faut, c’est essayer d’en réduire le coût…
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
Principles and patterns for test driven developmentStephen Fuqua
Developed to help introduce key topics in Test Driven Development, for new and veteran developers alike. Some examples are language-specific (C# / MSTest / Moq), but the principles apply to any object oriented language.
Ever wondered why NUnit is such a good unit testing framework?
Did you try understanding the true abilities of NUnit from their website and still left with questions?
then read this preety simple presntation about NUnit's top features!
For extensive information, please follow the notes.
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
Principles and patterns for test driven developmentStephen Fuqua
Developed to help introduce key topics in Test Driven Development, for new and veteran developers alike. Some examples are language-specific (C# / MSTest / Moq), but the principles apply to any object oriented language.
Ever wondered why NUnit is such a good unit testing framework?
Did you try understanding the true abilities of NUnit from their website and still left with questions?
then read this preety simple presntation about NUnit's top features!
For extensive information, please follow the notes.
C++ Testing Techniques Tips and Tricks - C++ LondonClare Macrae
Links from the talk are available at:
https://github.com/claremacrae/talks/blob/master/Cpp_Testing_Techniques_Tips_and_Tricks.md#top
Presented at C++ London Meetup, on Thursday, November 21, 2019.
Abstract:
An assortment of practical techniques to make it easier to write effective automated tests of C++ code, both old and new.
I share some approaches for easier handling of commonly troublesome testing scenarios. This is a brand new talk, that is independent of test frameworks, and even covers a little for those creating Qt desktop applications.
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
THE CHALLENGE:
Given you understand the value of test automation.
Given you are handed a legacy application to maintain and enhance
Given the application is in ASP.Net Web Forms
When you try to add tests
Then you find that test-driven development is literally impossible.
You’re finally doing TDD, but your past mistakes are catching up with you. No matter what you do, you can’t get rid of the gaping black holes caused by your legacy code.
In this presentation, we learn about the causes of legacy code and the reasons it is so difficult to work with. Then we discuss various techniques to test untestable code, revive and simplify incomprehensible code, redesign stable yet untested code, and repair that rift we created in the time-space continuum.
May: Automated Developer Testing: Achievements and ChallengesTriTAUG
Developer testing, a common step in software development, involves generating sufficient test inputs and checking the behavior of the program under test during the execution of the test inputs. Complicated logics inside a method make generating appropriate arguments difficult. In testing object-oriented programs, generating method sequences to put the receiver object or argument objects into appropriate states further complicates test-input generation. After the generated test inputs are executed, program crashes or uncaught exceptions can be used to indicate program problems, especially robustness problems. However, some program problems such as producing wrong program outputs do not crash the program.
In this talk, the speaker will present an overview of achievements and challenges in improving automation in developer testing, especially on test-input generation (i.e., generating sufficient test inputs) and test oracles (i.e., checking the behavior of the program under test).
About the speaker:
Tao Xie is an Associate Professor in the Department of Computer Science of the College of Engineering at North Carolina State University. He received his Ph.D. in Computer Science from the University of Washington in 2005. Before that, he received an M.S. in Computer Science from the University of Washington in 2002, an M.S. in Computer Science from Peking University in 2000, and a B.S. in Computer Science from Fudan University in 1997. He worked as a visiting researcher at Microsoft Research Redmond and Microsoft Research Asia.
His research interests are in software engineering, focusing on automated software testing and mining software engineering data. He has published more than 100 research papers in refereed journals and conference proceedings in the area of software engineering. Besides doing research, he has contributed to understanding the software engineering research community.
He has served as the ACM SIGSOFT History Liaison in the SIGSOFT Executive Committee as well as serving in the ACM History Committee. He received a National Science Foundation Faculty Early Career Development (CAREER) Award in 2009. He received 2008, 2009, and 2010 IBM Faculty Awards and a 2008 IBM Jazz Innovation Award. He received 2010 North Carolina State University Sigma Xi Faculty Research Award. He received the ASE 2009 Best Paper Award and an ACM SIGSOFT Distinguished Paper Award. He was Program Co-Chair of 2009 IEEE International Conference on Software Maintenance (ICSM) and is Program Co-Chair of 2011 and 2012 International Working Conference on Mining Software Repositories (MSR).
Writing useful automated tests for the single page applications you buildAndrei Sebastian Cîmpean
How to approach testing if you are building a modern single page application. I try to emphasize that integration testing is the way to go and that developers should consider the tests as part of the system and spend time to maintain them.
The natural way to develop software is to start with requirements - the expected behavior - of the system. We work our way through design to implementation and somewhere in there we write tests. Unit testing focuses on implementation, even if you write the tests first. Behavior-Driven Development lets you write the expected behavior in a testable format so that you can develop software outside-in, in a natural manner.
What is main difference between Behavior Driven Development and Acceptance Test Driven Development? How can we start using one of these practices. What books should you read to get more details about Testing By Specification?
Neutron is one of the most important and challenging OpenStack projects. Getting started as a Neutron contributor will put you at the center of the OpenStack revolution. In this session you will get an overview of the Neutron architecture and the tools (Git, Gerrit, Launchpad, Jenkins) you'll need to know to start contributing. We will also walk you through the development process from new feature proposal, to coding best practices, to change testing before submitting, and finally how to handle the review process and community interaction. By the end, you will be ready to start hacking on Neutron.
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)Jen Wong
FitNesse is a wiki-based software testing tool that can be a powerful addition to your Continuous Integration Environments. Its greatest advantages include providing visibility into tests and results, and providing access to test-writing by non-technical team members. We will:
* look at specific examples and code,
* discuss the advantages and drawbacks of using FitNesse as a test framework
* implement, deploy, and use a simple fixture in a fitnesse test
* review different kinds of fixtures, including decision table, script, query, html, and selenium webtest fixtures
* discuss some of the more interesting fixture extensions we've implemented, including JSON-based verification and the ability to pass in javascript code for dynamic verification
* use Hudson/Jenkins to run your FitNesse tests as a step in your Continuous Integration/Deployment process
A short presentation slide deck I gave to interns we have this summer of 2019 on (unit) testing in software development. This is not a code-centric slide deck and just looking at the slides loses some context without being there in person, or having discussions, etc.
Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in Visual C#, Visual Basic, and Visual C++ projects. A unit test can be created one time and run every time that source code is changed to make sure that no bugs are introduced.
C++ Testing Techniques Tips and Tricks - C++ LondonClare Macrae
Links from the talk are available at:
https://github.com/claremacrae/talks/blob/master/Cpp_Testing_Techniques_Tips_and_Tricks.md#top
Presented at C++ London Meetup, on Thursday, November 21, 2019.
Abstract:
An assortment of practical techniques to make it easier to write effective automated tests of C++ code, both old and new.
I share some approaches for easier handling of commonly troublesome testing scenarios. This is a brand new talk, that is independent of test frameworks, and even covers a little for those creating Qt desktop applications.
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
THE CHALLENGE:
Given you understand the value of test automation.
Given you are handed a legacy application to maintain and enhance
Given the application is in ASP.Net Web Forms
When you try to add tests
Then you find that test-driven development is literally impossible.
You’re finally doing TDD, but your past mistakes are catching up with you. No matter what you do, you can’t get rid of the gaping black holes caused by your legacy code.
In this presentation, we learn about the causes of legacy code and the reasons it is so difficult to work with. Then we discuss various techniques to test untestable code, revive and simplify incomprehensible code, redesign stable yet untested code, and repair that rift we created in the time-space continuum.
May: Automated Developer Testing: Achievements and ChallengesTriTAUG
Developer testing, a common step in software development, involves generating sufficient test inputs and checking the behavior of the program under test during the execution of the test inputs. Complicated logics inside a method make generating appropriate arguments difficult. In testing object-oriented programs, generating method sequences to put the receiver object or argument objects into appropriate states further complicates test-input generation. After the generated test inputs are executed, program crashes or uncaught exceptions can be used to indicate program problems, especially robustness problems. However, some program problems such as producing wrong program outputs do not crash the program.
In this talk, the speaker will present an overview of achievements and challenges in improving automation in developer testing, especially on test-input generation (i.e., generating sufficient test inputs) and test oracles (i.e., checking the behavior of the program under test).
About the speaker:
Tao Xie is an Associate Professor in the Department of Computer Science of the College of Engineering at North Carolina State University. He received his Ph.D. in Computer Science from the University of Washington in 2005. Before that, he received an M.S. in Computer Science from the University of Washington in 2002, an M.S. in Computer Science from Peking University in 2000, and a B.S. in Computer Science from Fudan University in 1997. He worked as a visiting researcher at Microsoft Research Redmond and Microsoft Research Asia.
His research interests are in software engineering, focusing on automated software testing and mining software engineering data. He has published more than 100 research papers in refereed journals and conference proceedings in the area of software engineering. Besides doing research, he has contributed to understanding the software engineering research community.
He has served as the ACM SIGSOFT History Liaison in the SIGSOFT Executive Committee as well as serving in the ACM History Committee. He received a National Science Foundation Faculty Early Career Development (CAREER) Award in 2009. He received 2008, 2009, and 2010 IBM Faculty Awards and a 2008 IBM Jazz Innovation Award. He received 2010 North Carolina State University Sigma Xi Faculty Research Award. He received the ASE 2009 Best Paper Award and an ACM SIGSOFT Distinguished Paper Award. He was Program Co-Chair of 2009 IEEE International Conference on Software Maintenance (ICSM) and is Program Co-Chair of 2011 and 2012 International Working Conference on Mining Software Repositories (MSR).
Writing useful automated tests for the single page applications you buildAndrei Sebastian Cîmpean
How to approach testing if you are building a modern single page application. I try to emphasize that integration testing is the way to go and that developers should consider the tests as part of the system and spend time to maintain them.
The natural way to develop software is to start with requirements - the expected behavior - of the system. We work our way through design to implementation and somewhere in there we write tests. Unit testing focuses on implementation, even if you write the tests first. Behavior-Driven Development lets you write the expected behavior in a testable format so that you can develop software outside-in, in a natural manner.
What is main difference between Behavior Driven Development and Acceptance Test Driven Development? How can we start using one of these practices. What books should you read to get more details about Testing By Specification?
Neutron is one of the most important and challenging OpenStack projects. Getting started as a Neutron contributor will put you at the center of the OpenStack revolution. In this session you will get an overview of the Neutron architecture and the tools (Git, Gerrit, Launchpad, Jenkins) you'll need to know to start contributing. We will also walk you through the development process from new feature proposal, to coding best practices, to change testing before submitting, and finally how to handle the review process and community interaction. By the end, you will be ready to start hacking on Neutron.
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)Jen Wong
FitNesse is a wiki-based software testing tool that can be a powerful addition to your Continuous Integration Environments. Its greatest advantages include providing visibility into tests and results, and providing access to test-writing by non-technical team members. We will:
* look at specific examples and code,
* discuss the advantages and drawbacks of using FitNesse as a test framework
* implement, deploy, and use a simple fixture in a fitnesse test
* review different kinds of fixtures, including decision table, script, query, html, and selenium webtest fixtures
* discuss some of the more interesting fixture extensions we've implemented, including JSON-based verification and the ability to pass in javascript code for dynamic verification
* use Hudson/Jenkins to run your FitNesse tests as a step in your Continuous Integration/Deployment process
A short presentation slide deck I gave to interns we have this summer of 2019 on (unit) testing in software development. This is not a code-centric slide deck and just looking at the slides loses some context without being there in person, or having discussions, etc.
Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in Visual C#, Visual Basic, and Visual C++ projects. A unit test can be created one time and run every time that source code is changed to make sure that no bugs are introduced.
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
Automated php unit testing in drupal 8Jay Friendly
An overview of PHPUnit Automated testing in Drupal 8, including a comparison of manual testing vs automated testing, the pros and cons of automated testing, and the types of automated tests available in Drupal 8.
Techorama 2017 - Testing the unit, and beyond.Bert Brouns
Cegeka Partner Session @ Techorama 2017
Everybody is writing unit tests, right? And do you write them the classic way or not? Did you ever question that?
During this talk we’ll be asking ourselves what the scope of a unit test can or should be. And we’ll show techniques to help you write more meaningful unit tests, which help us to involve the customer and to speed up an agile team.
We’ll also touch on the impact of new technologies which could blur the lines between unit testing and integration testing.
Integration and Unit Testing in Java using Test Doubles like mocks and stubsRody Middelkoop
Integration and Unit Testing in Java using Test Doubles like mocks and stubs. More info: https://git.icaprojecten.nl/stash/projects/RODMIDDE/repos/asd-talks/browse
Beginners - Get Started With Unit Testing in .NETBaskar K
Beginners - Get started with unit testing in .NET. Introduction to unit testing and mocking.. List of unit testing frameworks available in .NET - NUnit, xUnit.net, Visual Studio unit test framework. List of mocking frameworks available in .NET - Moq, Rhino Mocks, FakeItEasy, NSubstitue, JustMock, and TypeMock. Introduction to Visual Studio Unit Testing Framework, NUnit and xUnit.net.
Presentation to Craft CMS Meetup group in Charlotte, NC USA on November 13, 2019. Topic revolves around testing within the Craft framework using Codeception, as well as testing emails with Mailtrap and other types of tests. ~30 min read.
We investigate one of the most popular approaches to creating software: test driven development. From the basic understanding why tests are important to a new software development paradigm, where you start with tests and them do the implementation. We glance over different areas of testing and see how one should really do the software testing in different situation.
Test Driven Development, or TDD, is the mainstream in many areas of software development, but what about the database? In this session, we explore TDD, the benefits of automated testing, and how testing data projects differs from other types of development. We introduce the tSQLt testing framework and demonstrate its use with a live coding example. Finally, we will discuss some lessons learned in doing TDD with SQL Server.
Originally presented by Steve Fibich and David Moore at Richmond SQL Server Users Group on January 11, 2018
Системный взгляд на параллельный запуск Selenium тестовCOMAQA.BY
Параллельный запуск тестов – не просто желание, но острая необходимость, стандартная задача, с которой рано или поздно столкнется каждый проект, за исключением, разве что, совсем небольших и краткосрочных. Порой, вопрос параллелизации тестов превращается в сложный или даже почти невыполнимый. Давайте поговорим о том, как избежать подобной ситуации: какие рекомендации и инструменты существуют, какую архитектуру стоит выбрать изначально, каких решений следует избегать. Антон попробует ответить на все эти актуальные вопросы и конечно приведет множество примеров для наглядности и практического подтверждения. Мы проговорим «хорошие» варианты параллельного запуска автоматизированных тестов, но так же рассмотрим ситуацию с противоположной стороны «от противного». Проанализируем десяток «плохих» решений по параллелизации на реальных примерах – сложных, медленных, дорогих, неэффективных. Фактически, беседа будет состоять из двух частей: «что такое хорошо и что такое плохо» в примерах, с аргументацией и рекомендациями.
This talk demonstrates advanced testing practices coming from the STAMP research project and applied to the XWiki open source project:
- Testing for coverage with Jacoco and defining a viable strategy for slowly improving the situation
- Testing the quality of your tests with Descartes Mutation testing
- Automatically enriching your test suite with DSpot
- Testing various configurations with Docker containers and Jenkins
- Generating tests automatically from production stack traces
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Unit tests = maintenance hell ?
1. Unit Tests = Maintenance Hell ?
Thibaud DESODT
@tsimbalar
2. This talk
• About Unit-Testing
– Why we do it
– Why it can slow you down
– How to ease the maintenance
• Include :
– .NET-based examples / tools
– … can be applied to other platforms
4. Value of Unit tests
• Benefits
Value of Unit tests
–
–
–
–
–
“toy”
projects
Avoid introducing bugs
Executable documentation
Regression detection
Know when to stop
Reduce fear / allow
refactoring
–…
Unit-tests help build CONFIDENCE
Codebase size
6. Quantity of Test Code
• Prod Code vs Test Code Ratio
– from 1:1 to 1:5 !
More Test Code than Prod Code !
• Muliplied efforts :
– New Code
– Changing existing code
7. Lower Quality of Test Code
• Viewed as less important than Prod Code
– “Write Once”
– Duplication / Copy+Paste
– Less refactoring / improvements
– Hard to read/understand
• Technical Debt reduction has less priority
8. Cost of Unit tests
Cost of Unit Tests
Unit-tests introduce FRICTION
Codebase size
12. Maintainability of codebase
Solution 1 : give up on Unit Tests
“Legacy Code is code without Tests”
Michael Feathers
Working Effectively with Legacy Code
Codebase size
13. WIN !
Value vs Cost of Unit tests
Solution 2 : reduce the cost
of test maintenance !
Codebase size
16. Tools to manage thousands of tests
–
–
–
–
Exploring tests / results
Run All
Run/Debug Current Test
Run All Tests in current
Test Class
– Re-run last executed
tests
–…
• VS2012 Test Explorer
– Just kidding !
• Telerik JustCode
• JetBrains ReSharper
17. Continuous Testing
• NCrunch !
–
–
–
–
Runs tests continuously
Reports results without rebuilding or saving the files !
Impacted tests are run first
Tests run in parallel
• Expensive but worth it ! (159$/289$)
– Give it a try http://www.ncrunch.net/
– Free alternative : http://continuoustests.com/
19. Define conventions
Convention
Choice
Test Projects
[ProjectNamespace].Tests
Test Classes
One/class to test: [TestedClass]Test
Test Methods
[MethodName]_with_[Condition]_[ExpectedOutcome]
Structure
Arrange/Act/Assert or Given/When/Then
Helper methods In Test Class (private static)
In Test Project in namespace TestUtils
In dedicated project « Test Support »
Which convention you choose does not matter,
as long as it’s used by everybody !
20. Use « standard » variable names /
prefixes
• Common concepts :
– sut (System Under Test)
– actual (result of the action)
– expected (expected value for the result)
• Benefits :
– Makes tests more homogenous
– No need to think of it when writing the test
– Resistant to class renaming !
21. Typical structure
[TestMethod]
public void SomeMethod_with_SomeConditions_must_DoSomething()
{
// Arrange
var sut = MakeSut();
var expected = "what it should return";
// Act
var actual = sut.DoSomething();
// Assert
Assert.AreEqual(expected, actual, "Should have done something");
}
23. Use templates / snippets
• Commonly created items :
– Test Class
– Test Methods
– Test Helper Methods
• … and share them with the team !
• Examples :
– aaa, aae, any …
25. It will change !
“The only constant is change”
Heraclitus of Ephesus
5th century BC
• In 3 minutes / days / weeks …
• Be ready !
26. Constructors
• Dependency Injection entry point
– Changes when dependencies are added/removed
– Impact in every test !
• Encapsulate it in a helper Method
27. MakeSut()
private static ClassToTest MakeSut(
IDependency1 dep1 = null,
IDependency2 dep2 = null)
{
dep1 = dep1 ?? new Mock<IDependency1>().Object;
dep2 = dep2 ?? new Mock<IDependency2>().Object;
return new ClassToTest(dep1, dep2);
}
– Default value for dependencies
– Adding dependencies does not impact tests
28. Test Data creation
• Classes will change
– New properties
– Updated constructors ….
• Automate generation of « auxiliary » test
objects
29. AutoFixture
• Creates instances of
classes
var fixture = new Fixture();
var user = fixture.Create<User>();
– Populates constructor
arguments
– Populates properties
– Recursive
– Values derived from
Property names
> Install-Package AutoFixture
https://github.com/AutoFixture/AutoFixture/wiki/Cheat-Sheet
30. Test-specific comparison
• Comparing objects is common
– Actual vs expected
– Should not override Equals() for the tests
• Adding properties can break comparison
31. Semantic Comparison
var actualUser = new User(12, "john@rambo.com");
var expectedUser = new User(13, "tibo@desodt.com");
actualUser.AsSource().OfLikeness<User>().ShouldEqual(expectedUser);
Ploeh.SemanticComparison.LikenessException: The provided value
ProductionCode.Lib.Data.User did not match the expected value
ProductionCode.Lib.Data.User. The following members did not match:
- Id.
- EmailAddress.
actualUser.AsSource().OfLikeness<User>()
.Without(u=> u.Id)
.ShouldEqual(expectedUser);
> Install-Package SemanticComparison
33. Working with many Unit Tests
• … is hard
• Requires extra care
– Up-front
– During code maintenance
• But pain can be reduced
by:
– Appropriate tools
– Good habits
TIPS
#1 Proper Tools
– Good Test Runner
– Continuous Tests
#2 Get organized
– Conventions
– Naming
#3 Make Writing Tests Cheap
and easy
– Templates/snippets
#4 Prepare for changes
– Encapsulate constructors
– Automate object Creation
– Automate object comparison
34. Recommended read
• xUnit Test Patterns: Refactoring Test
Code by Gerard Meszaros
– http://xunitpatterns.com/
• Zero-Friction TDD by Mark Seemann
– http://blog.ploeh.dk/2009/01/28/ZeroFrictionTDD/
French software developer.NET web-apps for the French GovernmentAgile software team using Scrum … in BelgiumColleagues say I have some kind of obsession with Unit-Testing … they may be rightInterest in automated testing / unit-testing in particular 2-3 years agoI struggled a bit at the beginning, unit-testing + TDD in a legacy project. hard, but started to feel comfortable - adding = more fun and exciting. Triedto improve my skills, reading a lot about the topic and experimentingMy name is Thibaud DESODT , I am a French software developper, currently working in Belgium for the French government. I work in a small Scrum team on the development of .NET-based web applications. According to my colleagues, I have some kind of obsession about unit tests ... the truth is they may be right .... I started to get interested in automated testing and in unit-testing in particular 2-3 years ago. As most of us did, I struggled a bit at the beginning, trying to apply unit-testing and TDD to the current legacy project. It was hard, but I soon started to feel more comfortable and it made adding features to the system a bit more fun and exciting. Since then, I've tried to improve my skills, reading a lot about the topic, and trying new things in the projects I work on.
Enough about meIt’s not about : Integration Testing, Manual Testing, TDD … When it feels like they are slowing you down … how to reduce that feeling and get more productive on codebases with lots of unit-testsTargets people with previous knowledge of Unit-testingenough about me .... this talk is about Unit-Testing (not integration testing, not manual testing ...) ... when it starts to feel like they are slowing you down, and how to avoid or at least reduce that feeling. I'll talk a bit about unit-testing in general and then I'll try to provide tips to improve test maintenance. Because I am a .NET developer, most of the code and tools I'm going to show are related to the .NET ecostystem, but I guess most of the ideas can apply to other development platform ... (oh and yes, there won't be any VB.NET , sorry ;) ).
Shorter Feedback loops require more automationMore automation requires more confidence
With small projects, Unit Tests don’t provide so much valueBut as soon as the codebase grows, you need confidence to move forward … and Unit Test’s value gets bigger
Problems with unit tests over time : All those unit tests may slow us downit can feel like we struggle / they slow us down ...mostly because it's more code to maintain ! some kind of duplication
there are lots because they are the most granular part and least fragile ! (test pyramid)Just the number makes it hard to manage and have a good view of all the unit tests in the project
usually more Loc than production code 1:1 to 1:5 !Each line of code in prod means at least 2 lines of code to maintain
Writing tests is actually expensive !
Writing tests is actually expensive !
Let's review some best/worst practices to see WHAT TO DO and WHAT NOT TO DO when working with code bases with lots of unit tests .... in some random order ... some very specific and technical, some more general
Once you reach several hundred/thousands unit tests, you need good tools to manage / run your tests.Does anybody use the default Visual Studio Test Runner ? do you like it ?ReSharper Test-runner ! . or others (CodeRush ? Driven ? )You want to be able to : - run current test- run tests in current test class- run tests in current namespace- run tests in current project- run ALL tests+ re-run last run
Bonus : do not forget to run unit tests !Best way = run them constantly NCrunch ! show how it works(alternative : MightyMoose ?)
Let's review some best/worst practices to see WHAT TO DO and WHAT NOT TO DO when working with code bases with lots of unit tests .... in some random order ... some very specific and technical, some more general
It’s hard to maintain an unheterogenous Test Code Base !It’s hard to findwhatyour are looking forIt’s hard to add tests in it
Quick demo des Snippets
Who uses dependency injection ?UserNotificationServicewhichsends an email to a user …Wewantit to alsosend an SMS-> introduce a new constructor argument
Ajout d’un paramètre PhoneNumber sur User … impact sur les tests alors que la valeur a peu d’importance
Envoi du SMS … si on ajoute une propriété à SMS que devient la comparaison ?