Best way to implement automated tests #2294
Replies: 1 comment
-
I'm glad to hear they want to invest in automated testing, I think that's great! There are different types of testing, and different ways to do this. You can implement true unit testing. You can implement low level integration testing. You can implement high level integration testing. You can implement even higher level testing, all the way up to automated user-level testing with something like Selenium. From your question I'm thinking you are talking about unit testing and low level integration testing. These are so similar to each other that a lot of people don't differentiate between them (usually including me). CSLA 5 and 6 support some nice features for "true" unit testing. That's a fair amount of work in any framework, because it requires building mocks and a bunch of other stuff. Very doable, just requires some work. This is simplified with the use of dependency injection, which you can use to inject mocks instead of real types. Something a little closer to integration testing where you use a mock database (in memory like I often do in my examples) can be a lot easier. Of you can find your own path in the middle. The thing is, if you use CSLA rules, then you can write unit tests for each rule individually. Prove the rules do their job. That reduces the need to test each property in detail, as long as you establish the the appropriate rules are attached to each property. You should be able to trust that CSLA is running the rules, and you've tested your rules. There's an API in CSLA (BusinessBase) where you can get the list of rule URIs attached to each property, so if you've tested all your rules, you can also test which rules are attached to each property. Then you can test your DAL, especially if you use the encapsulated invocation or factory data access models. This usually does require a database you can reset to a known state, just like any data access level testing. Probably the hardest thing imo. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question. The particular company I work for doesn’t currently use any automated testing process. We’d like to get into doing them, but I’m not sure how to begin. CSLA objects can have any number of business rules, obviously. Should we be writing separate test methods for each business rule? Should we just CRUD objects and verify that all the rules are satisfied using test data? Any help on this would be appreciated because I’m not sure the best way to go about it.
Beta Was this translation helpful? Give feedback.
All reactions