Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would you include in a 10 min Grok talk on Unit Testing

I'm soon to do a 10min Grok talk on Unit Testing at my company. I've been trying it myself, and feel that it can certainly bring benefits to the company. We already do WebInject testing in our dedicated QA team, But I want to try and sell unit testing to the devs.

So with only 10mins what would you cover and why?

  • we're a Microsoft Shop C# Web Apps, I've used NUnit in my experience.
like image 497
danswain Avatar asked Feb 04 '09 13:02

danswain


People also ask

What should be included in unit testing?

A unit test typically features three different phases: Arrange, Act, and Assert (sometimes referred to as AAA). For a unit test to be successful, the resulting behavior in all three phases must be in line with expectations.

How do you introduce unit testing?

To perform unit testing, you have to test every output of your code unit with their expected return value to confirm if they adhere to their contract. Run your tests to confirm if your code unit is working as expected. Now, say you were to change the expected output of your test to a wrong value.

What are the three essential is related to unit testing?

In the overall view of any unit test application, we will see that a unit test is a three-step processes. The first one is setup test or arrange test, Act test or execute unit test and Assert means verify test result with expected results. The concept of three "A"s are given below.


2 Answers

Unit testing is all about confidence.

It allows you to be confident that your code is solid, and that other people can rely on it when they're writing their own parts of a system. If you can get across that unit testing will help to eliminate the trepidation that comes with the first release of a new system, I would hope that your audience will soon become very interested.

like image 180
David Grant Avatar answered Oct 26 '22 22:10

David Grant


I'd start with a problem a lot of programmers might be familiar with: that is the fear of making a change to existing code because of the fear they might break something. How that prevents work from happening, or prevents it being done properly (because they're afraid to refactor) and so leads to having to rewrite everything every x years.

Unit Testing -> Refactoring -> Living Code.

Edit: btw, I would Not lead with the 'all code without unit tests is legacy code' quote from Michael Feathers. It certainly made me feel defensive the first time I heard it. By the time people stop feeling affronted the 10 minutes will be over :-)   (personally I think that quote is more true than it is helpful).

like image 29
codybartfast Avatar answered Oct 26 '22 23:10

codybartfast