makes your team most productive > But also, yes. Source: https://www.linkedin.com/posts/jasonswett_tdd-has-an-unfortu nate-reputation-as-being-activity-7344036407851552769-pui S?utm_source=social_share_send&utm_medium=member_deskt op_web&rcm=ACoAACjWRfQBqoHqXoHElKhBhOCEhsPQacL B1q0
> We want to be sure that the changes we make in one place don’t break the entire system. > Tests act as an early warning system. > “Testing isn’t just about catching bugs, it is living documentation” ~ David Caixinha, ElixirConfEU 2019 Source: https://www.youtube.com/watch?v=uc5aoM_WDqk
auction bidding site. It will have 3 models ( Users, Auction Items and Bids ). > A user can have many auction items and many bids. > An auction item can have many bids, but belongs to one user. > A bid belongs to one auction item and one user.
the system. > Improves overall reliability of the system > Mock or stub dependencies like database calls in order to focus solely on the logic of the component being tests.
of the system. > Typically use tools to simulate interaction with the application’s interface. > In our demo project this would involve testing the application’s ability to create a user, create an auction item, create a bid, close the auction and award the auction item to the highest bidder.
testing, used mostly with microservices. > It captures the interactions exchanged between services, stores them in a contract and then the contract is verified to be what is expected. > Each service can be tested independently of each other with the contract being generated by the code itself. Source: https://pactflow.io/blog/what-is-contract-testing/
will be unit tests ( If you follow the testing pyramid at least ). As such we will focus on writing unit tests. • What are the key tenets of unit testing? ◦ Tests should be Isolated ◦ Tests should be deterministic ◦ Tests should have a single responsibility ◦ Tests should be self descriptive • There are other tenets, but we will focus on these 4
an isolated test Why is this an isolated test Test A Test B Mocks, Stubbing and Doubles These techniques allow developers to isolate the unit of code being tested by replacing its dependencies with controlled substitutes. Source: https://softwarepatternslexicon.com/patterns-ruby/15/4/
Test guidelines will vary from person to person, team to team. > This is a test sample test guideline by Nathan Long and Yury VeliKanau, both software engineers at GridPoint
codebase, and your first task is to update the currency situation. Your supervisor wants you to use Euros as opposed to Dollars for auction item listings. > Where do you start?
step ) > Understand how your team approaches testing. Read their testing guidelines > Recall that tests are a form of living documentation, so by reading the tests you are in fact reading the docs. Reading Tests
That is, if your task is focusing on users, don’t start reading tests focusing on auctions. > Expand the tests you read based on the problem dependencies. ** You should also know that some tests are terribly written and they will not always help you in learning about the codebase. ( Writing *good* tests will help you learn how to spot bad tests ) Reading Tests
on the same page 2. Tests are crucial guard rails and also living documentation 3. Write tests for future developers, and for your future self. 4. Writing tests makes you better at reading and identifying unconventional tests. 5. It’s never “This is not testable”, but instead, “This is not testable, yet” Key takeaways
recommend you should checkout and contribute to. > Ladybird browser by Andreas Kling ( https://ladybird.org ) > Serenity OS by Andreas Kling ( https://serenityos.org/ ) > Bitcrowd RaG ( https://bitcrowd.net ) > CoRecursive Podcast ( https://corecursive.com/ ) > Ruby Friend App, by Joe Masilloti ( https://rubyfriends.app/ )