background preloader

UML, Design

Facebook Twitter

The Pragmatic Bookshelf. Alec Sharp, in the recent book Smalltalk by Example[SHARP], points up a very valuable lesson in few words: Procedural code gets information then makes decisions. Object-oriented code tells objects to do things. . — Alec Sharp That is, you should endeavor to tell objects what you want them to do; do not ask them questions about their state, make a decision, and then tell them what to do. The problem is that, as the caller, you should not be making decisions based on the state of the called object that result in you then changing the state of the object. The logic you are implementing is probably the called object’s responsibility, not yours. Sure, you may say, that’s obvious. It is easier to stay out of this trap if you start by designing classes based on their responsibilities, you can then progress naturally to specifying commands that the class may execute, as opposed to queries that inform you as to the state of the object.

Just the Data Invariants aren’t enough // Called as: Law of Demeter. Principles of Test Automation at XUnitPatterns.com. The book has now been published and the content of this chapter has likely changed substanstially. About This Chapter In the Goals of Test Automation narrative chapter I described the goals we should strive to achieve to help us be successful at automating our unit tests and customer tests. In the Philosophy Of Test Automation narrative I discussed some of the differences in the way people approach software design, construction and testing. This provides the background for the principles that experienced test automaters follow while automating their tests. I call these principles because they are too high level to be patterns and because they represent a value system that not everyone will shared.

A different value system may cause you to choose different patterns than the ones I would choose. The Principles When Shaun Smith and I came up with the list in the original Test Automation Manifesto [TAM], we were considering what was driving us to write tests the way we did. Fragile Test at XUnitPatterns.com. The book has now been published and the content of this chapter has likely changed substanstially.Please see page 239 of xUnit Test Patterns for the latest information. A test fails to compile or run when the system under test (SUT) is changed in ways that do not affect the part the test is exercising. Symptoms We have one or more tests that used to run and pass which either fail to compile and run or fail when they are run. When we have changed the behavior of the SUT in question this change in test results is expected, but when we don't think the change should have affected the tests that are failing or we haven't changed any production code or tests we then have a case of Fragile Test.

Past efforts at automated testing have often run afoul of the "four sensitivities" of automated tests. Impact Fragile Tests increase the cost of test maintenance by forcing us to visit many more tests each time we modify the functionality of the system or the fixture. Trouble-Shooting Advice Causes Symptoms. Classicist vs. Mockist Test-Driven Development | Ian Cooper. One thing that came up in a couple of sessions of Altnetconf UK was the old saw of classicist vs. mockist approaches to TDD.

Martin Fowler has a great, and updated, article on the distinction between the two approaches here. Now I have to confess to being a classicist. I tried being a mockist, but I gave it up because of the dangers of over-specified software. Now I tend to favor test doubles for the areas that are difficult to get under test otherwise as per Michael Feathers. We are also much more inclined to use a stub or fake than a mock. Now some folks seemed to feel that if you had used concrete dependencies or associations in a test, you were not writing a unit test, and thus not using TDD properly. I see the origin of the unit test mantra, Fowler calls TDD in the classicist model mini-integration tests over unit tests, but I reject the latter accusation that this is not, somehow, TDD.

This entry was posted in altnetconf, AltNetUK, Fakes, Featured, Mocks, Stubs, TDD. Download?doi=10.1.1.100. Mocks and Tell Don’t Ask | Ian Cooper. One of our alumni Karl blogged a request recently for folks to stop using mocks. Once upon a time I also made clear that I had a significant distrust of mocks. I’ve mellowed on that position over time, so I thought that I should explain why I have changed my opinion. Perhaps it would be useful to give a summary of the discussion around this. Whilst I don’t think that you need to choose between being a classicist or mockist, I think that Martin Fowler’s article on Mocks Aren’t Stubs is still a good starting point for understanding the debate, because it talks about the different types of Test Double, as well as outlining approaches to their usage.

However, for my part, Martin does not highlight Meszaros’s key distinction between replacing indirect inputs and monitoring indirect outputs. Both mention the danger of Over-specified Software from Mocks, and Meszaros cautions to Use the Front Door. But this leads to the question: how do we confirm the post-conditions if we have no getters?

Patterns

Pattern. UML tools for software development and modelling - Enterprise Architect UML modeling tool.