Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First start with acceptance tests <strong>to drive your development</strong> (Outside in). You'd need to write the following scenarios:</p> <p><strong>User try to register with an invalid email</strong></p> <p>This is one is pretty easy</p> <p><strong>User try to register with an already existing login name</strong></p> <p>For this one you'll need to be able to plug your application on an <strong>in memory repository</strong> (I'd suggest using an <strong>IoC Container</strong> to easily configure your application). That way you'd first use your app to register a 'Bob' user and see what happen when you try to register again with that login. So basically the solution is to use the <strong>Repository Pattern</strong>, and have an in memory implementation instead of your real DB implementation. I assume here that your DB doesn't contain any business logic, otherwise it would be safer to use the real DB so that you can exercise the business rules in the DB. That's pretty common in legacy systems. The advantage of the in memory repository is that your tests will run faster and you won't need to write complicated tear down code. With the real DB you'll need to make sure that the DB is cleaned between each tests to insure tests independence, and running tests with the DB is a lot slower.</p> <p><strong>User successfully register</strong></p> <p>For this one you will need to check for the redirection which is pretty easy. For the email part, agian, you'll need to plug your app on a stub using the <strong>Adapter pattern</strong>. You can implement the stub like an <strong>in memory queue</strong>, that way you will be able to assert if the email was correctly sent by your application.</p> <p><strong>Regarding unit tests</strong></p> <p>If you are planning to write the email syntax verification on your own, I'd suggest to unit test that part on its own.</p> <p>As Augusto mentionned, <a href="http://www.bookdepository.co.uk/Growing-Object-Oriented-Software-Guided-by-Tests-Steve-Freeman/9780321503626" rel="nofollow">Growing Object-Oriented Software, Guided by Tests</a> is great book to learn ATDD and TDD.</p> <p>The general strategy is to always start with high level acceptance tests to drive your development. Mock external services that you can't run in memory or services that you can't install locally or are not easy to test. Unit test using TDD when it makes sense.</p>
 

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