At present, I have studied TDD and read a good book "test driven development: by example". it's not over yet. :) the first half of this book is still messy. Maybe it's because I haven't reached the level of English.
Our company currently uses the duwamish five-layer architecture development. For a simple function, such as the creation of a customer, there will be five classes to support. How can I write the test code ??
Currently, almost all examples I have seen are completed in a class, such as the nunit built-in example and account, which corresponds to an accounttest class. I want to analyze the five-layer architecture and ask you for advice. How can I write the test code?
1. There seems to be no good test on the bottom data layer?
2. dataaccess is difficult to test at this layer. Why? Each class has certain function calls to process crud operations of related business entities.
3. The businessrule layer verifies the database field length, whether the email address is valid, and whether the customer exists.
4. businessfacade, also known as the businesssystem layer, acts as a proxy and seems to have nothing to test?
5. On the web layer, the page is displayed. The pagebase method is used. Specifically, here we add a customer and make some simple page control.
In conclusion, I think the test is only performed at the businessrule layer.
Through a recent study, I have understood the limitations between the test code and the real code.
For example, email Verification
In actual code, I want to check whether the email is correct. Of course, I also need to provide the corresponding error message! If it is correct, what will happen? Errors, etc.
Then, I put some valid addresses and invalid addresses in the test code and run this code to check whether the expected values in the actual code are obtained!