I regularly encounter this problem, and I'm not sure how to overcome this obstacle. I really want to start learning and apply Test-Driven-Development (or BDD, or something else), but it looks like every application I make where I want to apply is pretty much just a standard CRUD database, and I'm not sure how to apply it. Objects to a large extent do nothing except that they are stored in a database; there is no complicated logic that needs to be verified. There is a gateway that I will eventually need to test for a third-party service, but I want to create the application core first.
Whenever I try to write tests, I end up testing the basic materials, which I probably shouldn't test in the first place (like getters / seters), but this doesn't look like the objects have anything else. I guess I could check the perseverance, but it never seems right to me, because you shouldn't actually click on the database, but if you scoff at it, you really don't test anything, because you control the data that spits back; for example, I saw many examples where there is a repository layout that mimics the database by cycling and creating a list of known values, and the test verifies that the "repository" can drop a certain value ... I am not seeing the point of such a test, because of course , the "repository" is about to return this value; it is hardcoded in class! Well, I see this from a pure TDD point of view (i.e. you need to have a test saying that your repository needs a GetCustomerByName method or something else before you can write the method itself), but this seems like the following dogma without for any reason other than its "path" - the test does not seem to do anything useful except to justify the method.
Am I thinking about it wrong?
For example, launch the mill contact management application. We have contacts and we can say that we can send messages to contacts. Therefore, we have two objects: Contact and Message , each of which has common properties (for example, first name, last name, email address for the contact and subject and body, and date for the message). If none of these objects have any real behavior or should not execute any logic, then how do you use TDD when developing an application like this? The only purpose of the application is to basically pull out the list of contacts and display them on the page, display a form for sending a message, etc. I don’t see any useful tests here - I might think of some tests, but they would be more of a test in order to say "Look, I have tests!" instead of actually testing some kind of logic (although Ruby on Rails makes good use of it, I don’t think checking validation is a “useful” test because it should be something that the framework takes care of for you)
tdd
Wayne Molina May 09 '09 at 1:39 a.m. 2009-05-09 01:39
source share