kentcdodds / ama

Ask me anything!
https://github.com/kentcdodds/ama/issues?q=is%3Aissue+is%3Aclosed
685 stars 75 forks source link

Whats your Testing approach like❓ #381

Closed deadcoder0904 closed 6 years ago

deadcoder0904 commented 6 years ago

Hi Kent 👋

I read your blog post Write Tests. Not too many. Mostly Integration & was wondering how do you start with Tests. Like first Unit Test, then Integration & then E2E or some other way❓

Also, do you follow TDD❓

What are your steps as I'm planning to write more tests from now on❓

Also what is the use of Unit & Integration if I use E2E as I'm basically building a web app & the way I used to test things manually was through the browser like E2E & not calling function with params like Unit or Integration❓

kentcdodds commented 6 years ago

Hi @deadcoder0904!

For anyone wondering, here's a link to that blog post: http://kcd.im/write-tests

how do you start with Tests. Like first Unit Test, then Integration & then E2E or some other way❓ Also, do you follow TDD❓

There's no science to it. I write the test that makes sense for what I'm writing.

What are your steps as I'm planning to write more tests from now on❓

My steps? I think it's important to make sure you have a testing framework configured and ready to go. Write a few tests for existing components and find areas where you could make simple testing utilities for your codebase, then make those easy to import from other tests. Then integrate testing into your workflow while building stuff.

Also what is the use of Unit & Integration if I use E2E as I'm basically building a web app & the way I used to test things manually was through the browser like E2E & not calling function with params like Unit or Integration❓

Every level of testing comes with benefits and trade-offs. Give my talk "What we can learn about testing from the wheel" a watch. Also, watch the my talk "Write tests. Not too many. Mostly integration." where I justify several of the forms of testing.

Good luck!

deadcoder0904 commented 6 years ago

Wow that was fast. Thanks Kent, love your talks, blogs, tweets, code & everything else 🎉

I am going to write some tests now. Ciao 👋