3. (…. your class) (…. your unit test) if () { inttempVariable; List<> for (some : List<>) booleaninnerFlag for (nested : loop) { //comment Map<Map<List>>.add } } } (Java Flab)
4. (…. your class) (…. your unit test) object.doSomething(with) object.otherThing(group.find) (Java Fab)
5. (…. your class) (…. your unit test) object.doSomething(with) object.otherThing(group.find) (it’s all good)
9. Thanks @markwshead Rich Hickey (made clojure) “What type of runner can run full speed from the very start of the race? Thats right. Someone who runs very short distances. But as programmers, we are smarter than that. We just fire the starter pistol again every 100 yards. I don’t know why runners haven’t figured that out.” (cough cough Scrum)
10. Rich Hickey (made clojure) “…do fewer semi colons make the customer happier?….” (sorry Groovy fans)
11. Thanks @markwshead Rich Hickey (made clojure) “We say, “I can make a change because I have tests.”… Who does that? Who drives their car around banging into the guard rails!?” Unit Tests == Guard Rails
12. Rich Hickey (made clojure) “…may keep you on the road, but won’t necessarily help you get where you are going….” Unit Tests == Guard Rails
13. Rich Hickey (made clojure) Does what you’re doing add value to the customer? (sorry for the business speak) (in regards to everything)
14. (hmm…..) Unit Tests No Semi Colons Fast Iterations (…who are these for more)
17. (update my code) (build the project) (eat sunflower seeds) (startup weblogic) (launch the app) (check email) (find correct test data) (test corner case 1) (check the happy path) (test corner case 3) (test corner case 2) (regression test 1) (regression test 2) (regression test 3) My mind on Testing
18. (update my code) (build the project) (eat sunflower seeds) (startup weblogic) (launch the app) (check email) (find correct test data) (find correct test data) (test corner case 1) (test corner case 1) (check the happy path) (check the happy path) (test corner case 3) (test corner case 2) (regression test 1) (regression test 2) (regression test 3) My mind on Testing
19. (update my code) (build the project) (eat sunflower seeds) (startup weblogic) (launch the app) (check email) (find correct test data) (test corner case 1) (check the happy path) (test corner case 3) (test corner case 2) (regression test 1) (regression test 2) (regression test 3) My mind on Testing
20. Rich Hickey (made clojure) Hey! The average person can only juggle 3 – 9 balls. Not 90 or 900 (mentally of course) (complexity)
21. (update my code) (build the project) (eat sunflower seeds) (startup weblogic) (launch the app) (check email) (find correct test data) (test corner case 1) (check the happy path) (test corner case 3) (test corner case 2) (regression test 1) (regression test 2) (regression test 3) My mind on Testing
22. (update my code) (build the project) (eat sunflower seeds) (startup weblogic) (launch the app) (check email) (find correct test data) (test corner case 1) (check the happy path) BUG (test corner case 3) (test corner case 2) (regression test 1) (regression test 2) (regression test 3) BUG My mind on Testing
29. “The hardest part of building a software system is deciding precisely what to build” Fred Brooks, The Mythical Man Month: Essays on Software Engineering, 2nd ed. (New York: Addison Wesley Professional, 1995).
36. 100% Coverage 50% Coverage 10 % Acceptance Tests Unit Tests Performance Tests C., Robert. The Clean Coder: A Code of Conduct for Professional Programmers. 2011. 115. Print.
37. Dev Verification User Verification Quality Software Code Reviews Automated Testing
38. Lisa Crispin and Janet Gregory, Agile Testing: A Practical Guide for Testers and Agile Teams. (Boston: Addison Wesley, 2009).
Unit tests are freedom!Do you feel unsure when making changes? Unit tests are the answer
Change the interface of the class and your tests are gone!
Unit tests are a brain protector from the entire app of complexity
It was all a suspicion until this guy
Okay, we’ve heard this story before. You have a new computer language that makes English executable… Right. And does it work in Swedish as well? Oh… it does. Well they’ve never made it that far before.Okay, so it’s the ability to write English (or Swedish) tests that executable, not English code that is executable. But that’s not all? That’s pretty much.So, it’s part of a bigger process called ATDD. That looks like it might be related to TDD.Really, so it has all of the same principles of TDD, but tests your application as a whole. So you get the regression test suite, right? And it serves as a living document? Sure. You’re saying that it helps you find problems in the requirements earlier and it encourages habits that form quality bug free code. Doubtful. My requirements and my code are already perfect. You have some explaining to do.
Cliché’. This is at the beginning of every software presentation.
This is Gherkin. It reads like English, runs like Byte code. You might not believe, but you’ll see.
ATDD tests the whole application. From the very edge of the database to the very end of the UI. Although, UI’s can be tricky to test at times, it’s best to have some type of separator between your test code and your production code. Code shouldn’t really directly interact with an AT.
Ifyour AT’s run just below the UI, remember that it’s always important to have a moat or some type of separator between your code and the code that’s running your tests. An HTML/HTTP form is a great example.
Then again there are some interfaces that provide just a bit more separation ;-)
What happens to development right now? Well at the end of the iteration we do a review with the user (probably the FA). YIKES! If you find a problem during that review, there is not much time at all to fix it. If it’s anything above minor, your task is going straight into the next iteration.
The problem might not even be the code that you’re writing. It may be holes or mistakes in the requirements. You try and sort those out before you start coding, but it sure is a lot of work. If you miss something you’re hosed.ATDD lets you address those types of issues right up front. The Cucumber test gives you and the FA something tangible to either agree on, or disagree on.Using ATDD is a lot like TDD in the sense that stuff is done just in time. You only write enough test to make it fail. Typically a few tests are written before the iteration begins, and all of the tests will be written by half way through the iteration.Who writes the tests you ask? Well typically the FA will write the tests for the “Happy Path”. QA will probably step in and round a few corner cases.
Wow! We already write a lot of unit tests. Won’t that be duplication.According Uncle Bob Martin, “no”. Acceptance tests are supposed to cover about 50% of the code. They won’t be covering every nook and cranny, but there will be enough to provide a solid suite of regression tests, and most importantly be an excellent document as to how the software works.
All of this is sounding very familiar…. Wait a second! Gary has been telling us to do this all along.When you write the AT with the FA, you’re performing User Verification.Having the runnable test scenarios kills two birds with one stone. It allows you to fulfill automated tests and provides you with super human developer verification.
Check it out. Q2. Not only are you helping you’re the other people out on your team, you’re also helping out the business and stake holders of the software.I didn’t even know that was possible.
These are the three magic words. Say them and you can make Cucumber do whatever you wish in Java bytecode
This is Gherkin. It reads like English, runs like Byte code. You might not believe, but you’ll see.
This is Gherkin. It reads like English, runs like Byte code. You might not believe, but you’ll see.
This is Gherkin. It reads like English, runs like Byte code. You might not believe, but you’ll see.
Whoa! This does not look like an AT….AT’s are supposed to have hundreds of lines of code. AT’s are really tough to understand, but this is so simple.Wait a second… Is that Regex!!!!!? That’s just mean man. Haven’t you ever heard the saying, “I tried solving a problem with Regex, then I had two”?
No way! Cucumber generates all of the Regex for you. That’s pretty nice.
Let’s see this thing in action.Here’s the form for scheduling test sets in automated analysis. It’s a web form let’s see what you do. And by the way my lunch is in 20 minutes.
Nice, so you’re saying that I can just insert variables into the English. English definitely can’t do that.
Sweet. They show up as arguments in each of the methods. That’s pretty cool.
Now tell me how Cucumber is going to keep this DRY. To check to see if each of those elements is on the page, you’re going to have write at least three different scenarios. Man we could do that in xUnit.
Ahh…. touché.So you can define one scenario, with just a table that has all of the different elements you want to check for. Nice
That could be really powerful, the fact that you receive a table construct with all of the appropriate values.
Alright, but now I want to see if these values actually get saved in the cache when we press save settings. You’re definitely going to have to write at least three different scenarios, because you have to submit each one individually. This will be slop-pay
What is this!?That is impressive. So you’re telling me that by specifying it as a “Scenario Outline” I can run the scenario for each of the rows in the table. What about those words in brackets?Oh… so those just plug in the corresponding value from the example table.This has to be complicated Java code behind the scenes.
Wow, Cucumber takes care of it all.We don’t even have any for loops or any tables to deal with!! That’s sweet man.You know what. Now that we have all of these tests, running this test suite is going to run sloooowwww. My tests have to run in under one second, because fast tests is a core tenet of TDD. So maybe this isn’t so TDDish after all.
Wait. So you can tag each of those scenarios with an annotation. What’s this @wip? Only scenarios that have marked as @wip run when you run your suite. Okay that’s really nice.
Can I annotate a scenario with ‘@onlyRunIfPizzaAvailable’?
So you’re saying that I should check out Paul Rayner’s guide to Cucumber and implementing ATDD. Interesting. Where is that at? Contact michael.p.menne@monsanto.com or find @thePaulRayner on Twitter. He sure was nice for providing all this material.Which chapter did you say that I should look at in Clean Coder? Ah… chapters 1 – 14. Got it.
So you’re saying that I should check out Paul Rayner’s guide to Cucumber and implementing ATDD. Interesting. Where is that at? Contact michael.p.menne@monsanto.com or find @thePaulRayner on Twitter. He sure was nice for providing all this material.Which chapter did you say that I should look at in Clean Coder? Ah… chapters 1 – 14. Got it.