public class TransactionService {
private TransactionProviderFactory transactionProviderFactory;
TransactionService(TransactionProviderFactory transactionProviderFactory) {
this.transactionProviderFactory = transactionProviderFactory;
}
public void transfer(Money money, String type)
{
transactionProvider = this.transactionProviderFactory.getFor(type);
transactionProvider.startTransaction(money);
}
}
class TransactionProviderFactory {
TransactionProvider getFor(String type) {
//returns for type
}
}
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
--
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
@MatteoAfter some time of thinking, you're right in here. I came with the solution first even that I wrote the tests first. I know, that is not way to do it, but the experience and habits are just strong. When I start to thinking of some problem, my brain tries to find solution immediately.So "Let the tests guide you." isn't so simple, like it sounds. :)
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
"When mocks get in the way of refactoring, it usually happens because I'm mocking an interface that is not a good abstraction for the domain"
Do you mean, that when we find correct abstraction for the domain, we will no need to change interaction between two objects while refactoring?
What about situation when the abstraction is correct, but we would like to delegate it to some other place (it will break the tests)?
I would love to see some of your code examples with tests, to better understand your way of thinking.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsu...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsu...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsu...@googlegroups.com.
This introduces a surprisingly complex responsibility of Detroit-school TDD practitioners: to define what level of realism is acceptable for a test to be called a "unit test". Rules similar to the ones published by Michael Feathers in 2005 are common and often debated within teams as suites grow and become slower.
By using test doubles as a convenience to work around slow dependencies or too-difficult-to-test situations (e.g. verifying a side-effect occurred), the unit tests in a Detroit-school suite tend to be heavily incidentally dependent on the behavior of the subject's dependencies. This acts as a double-edged sword: on one hand, when the behavior of a dependency changes in an unanticipated way, tests of its users will helpfully fail; on the other hand, large test suites will exhibit the problems caused by highly redundant coverage.
In contrast, London-school practitioners tend to have very clearly defined rules for when to use mocks. Because very few people in the broader public understand that there are two camps—much less the nuanced differences between them—a developer brought up in the Detroit-school will often look at a London-school unit test suite and immediately draw the conclusion that it has succumbed to extreme over-mocking."
Above comes from https://github.com/testdouble/contributing-tests/wiki/Detroit-school-TDD
when the behavior of a dependency changes in an unanticipated way, tests of its users will helpfully fail...
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
Nat, so are you in favor of using an InMemory implementation of an Repository if the objective is to control the indirect inputs of the SUT? Because if you stub a query method with a Mock Framework and that real implementation changes later, you won't get the "when the behavior of a dependency changes in an unanticipated way tests of its users will helpfully fail [...]" benefit.
Em sex, 28 de out de 2016 às 10:17, Nat Pryce <nat....@gmail.com> escreveu:
--On 28 October 2016 at 08:33, Dariusz Gafka <darius...@gmail.com> wrote:when the behavior of a dependency changes in an unanticipated way, tests of its users will helpfully fail...
I don't find the distinction between London/Detroit or Mockist/Classical useful. I've written about that before on this list. But this sentence highlights why:Mocks are a tool for testing objects that tell other objects either (a) "Make something happen!", or (b) "Something has happened, and you might need to react in some way!". The object should not care what behaviour results or even have visibility of it. If it does, a mock library is the wrong tool. In that case, I'd either use the same implementation of the dependency that is used in the deployed system, or write an in-memory implementation of the protocol between object and dependency, and use contract tests to ensure that it behaves the same as the implementation used in the deployed system.--Nat
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
On 28 October 2016 at 16:05, Israel Fonseca <israe...@gmail.com> wrote:Nat, so are you in favor of using an InMemory implementation of an Repository if the objective is to control the indirect inputs of the SUT? Because if you stub a query method with a Mock Framework and that real implementation changes later, you won't get the "when the behavior of a dependency changes in an unanticipated way tests of its users will helpfully fail [...]" benefit.Yes. If it's simple lookups, then it's easy to implement with a map. If it's a more complicated interface with a mix of queries and commands that have interrelated behaviour, then a contract test is even more important.--Nat
Em sex, 28 de out de 2016 às 10:17, Nat Pryce <nat....@gmail.com> escreveu:
--On 28 October 2016 at 08:33, Dariusz Gafka <darius...@gmail.com> wrote:when the behavior of a dependency changes in an unanticipated way, tests of its users will helpfully fail...
I don't find the distinction between London/Detroit or Mockist/Classical useful. I've written about that before on this list. But this sentence highlights why:Mocks are a tool for testing objects that tell other objects either (a) "Make something happen!", or (b) "Something has happened, and you might need to react in some way!". The object should not care what behaviour results or even have visibility of it. If it does, a mock library is the wrong tool. In that case, I'd either use the same implementation of the dependency that is used in the deployed system, or write an in-memory implementation of the protocol between object and dependency, and use contract tests to ensure that it behaves the same as the implementation used in the deployed system.--Nat
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.