# Clean Tests

### Connection - Mythbusters

Connect participants to the topic by making them relate on Facts and Myths regarding Unit Tests

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2FBocQMSK3skw52nEodjdm%2Fimage.png?alt=media\&token=99744eb9-f681-48b3-8f40-a31b26b7275f)

Debriefing is available in the slide deck

### Concepts

![](broken-reference)Before going further regarding the concepts, invite them to reflect on they define :

* What is a Unit ?
* Which tests they would write on the giving piece of code ?
* How they would write it ?

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2Fi2RXGHzqcvGPWr4gWaS0%2Fimage.png?alt=media\&token=a15e4e39-0a4b-421b-a4af-1cf65cf05446)

Then explain all those concepts :

* Schools of testing
* Pillars of Good Unit Tests
* FIRST Principles
* Anatomy of Unit Tests
* How to name your Unit Tests
* Styles of Code

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2F7OWDUirq0WwQgKplTfiI%2Fimage.png?alt=media\&token=f1ee677f-39f3-4edc-a7f8-6a16d56ad086)

### Concrete Practice - Anti-Patterns

In groups, make them identify Unit Tests anti-patterns by using Code snippets or the repository provided in this page.

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2FN8JOiaQuCeOoTfWgwWaW%2Fimage.png?alt=media\&token=13acdd4b-271f-4d19-b162-d07265f961b5)

You can debrief it directly on the Miro board or from the slides :

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2FAMq252xbEANwMzKNGs9c%2Fimage.png?alt=media\&token=736e7def-f238-493e-94e6-33871c0fbbf8)

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2FButhBO3KmmVUV8wNSIxp%2Fimage.png?alt=media\&token=b458b9b4-b7e8-4b1e-b8ac-05a0340799bc)

My identification logic and refactoring are explained in this step-by-step guide :&#x20;

{% embed url="<https://github.com/ythirion/clean-tests/blob/master/java/src/test/java/antipatterns/solution/step-by-step.md>" %}

### Conclusion

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2F6s8R6iR7d26mWdqn2Ovz%2Fimage.png?alt=media\&token=a38f7e5e-82a2-43a3-9a48-35605a46cac3)

### Resources

* Repository is available here : <https://github.com/ythirion/clean-tests>
* You can use the miro board here to facilitate this session : <https://miro.com/app/board/o9J_lpq9YGo=/?invite_link_id=764775433309>
* Slides are available here on speakerdeck :&#x20;

{% embed url="<https://speakerdeck.com/thirion/clean-tests>" %}
Clean Tests slides
{% endembed %}

* A lot of stuff from this workshop comes from the book "Unit Testing : Principles, Practices, and Patterns"by [Vladimir Khorikov](https://enterprisecraftsmanship.com/)

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MAffO8xa1ZWmgZvfeK2%2Fuploads%2F4ZRTayYWrm1sVjmx7fTd%2Fimage.png?alt=media\&token=2b8a0316-71e4-479e-9cd8-3fe94bc96f38)
