Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not familiar with C#, so i can't help you with the mock question, i guess that depend on your testing framework.</p> <p>I do do a lot of TDD though and generally my approach is a top down approach. I first think of simply the code I want to write to do something. Lets say in your example I have a class Client and want be able to do some thing like: Client.initiate_reviews</p> <p>So I write a test that sets up the context (a couple of clients, some with reviews). Then call Client.initiate_reviews, and then write up all assertions to determine whether it has done its job, i.e. for the subset of clients that was due for a review, is there now a review in progress and are all the expected sent?</p> <p>Depending on how many side effects a method has it might be prudent to split it up in multiple tests.</p> <p>I then go into the client class and define the method and think of the code I would want to write in it. Maybe like this:</p> <pre><code>clients = Client.find_all_due_for_review for_each client in clients { review = Review.start_new_for(client) Letter.send_for_review(review) } </code></pre> <p>I would then write the tests for the methods called in this method that I have to implement. The find_all_due_for_review doesn't have side effects, but return something so of course you would test the return value here and maybe whether nothing has changed. And repeat until the first test succeeds.</p> <p>This way every aspect is properly tested and you even end up with some methods you can reuse.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload