Tag Info

New answers tagged

2

It is absolutely not the responsibility of your coordinator to send mail, only to ask that it be sent. There are many reasons why a mail might not be sent, or delayed. It is the responsibility of your mail class to send valid mail reject invalid mail Log what it did (including unexpected failures to send valid mail) All your coordinator has to do, with ...


2

You generally don't need to test controller classes, since they shouldn't hold complex logic. The actual work should be done in other classes if it is written correctly, so in the end you're essentially ensuring that the work gets delegated correctly. The complexity of this depends entirely on the language that you're using, since to do it correctly, you ...


3

I don't think there is anything else that you can do except testing that the functions inside that method are called. Since the "orchestration" method doesn't contain much logic unit-testing is not so important. It's a method that only wires up other methods. It integrates other components. Therefore there should be integration tests that cover those lines ...


10

From what you describe I would say that the way you have been doing it - mocking the collaborators - is the best approach. It may be that you are over-specifying with your mock - for instance, requiring an order which is not really required by the business needs; if that is the case you could lighten up on the order requirements of your tests. But ...


2

Actually the same issue came up on a dojo last night. I did a quick research on it. This is what I came up with: Basically it is not forbidden explicitly by the TDD rules. Maybe some additional tests are needed to prove that a function works correctly for a generalized input. In this case the TDD practice is left aside just for a little while. Note that ...


5

In TDD, writing tests and code is interwoven, the cycles are typically very short, sometimes minutes, sometimes less. And TDD is a whitebox technique - when writing the next test, you know exactly what is missing in the current state of the implementation and you design the test exactly for this case. So if you really want to try this with two developers, ...


1

In order for unit tests to work you have to be able to mock all the external dependencies to your code (otherwise you're doing an integration test). Your problem is you have direct dependencies to your data access implementations. This is coupled with the problem that your handler is both doing it's handling work and is responsible for creating your data ...


2

Keep in mind that there is a difference between Unit Testing, which is the act of writing small tests that test individual units of your code, and Automated Test Runners which run your unit tests, usually as part of the build process or some kind of continuous integration system. Unit testing is commonly automated, but may still be performed manually. ...


0

It's important to understand TDD as less about the end result - tested code, and more about the journey in getting there. TDD is a design process that encourages all the code qualities I'm sure you have learned about: reusability, separation of concerns, readability, maintainability, etc. Oh, and of course, correctness. Your tests drive you towards writing ...


2

I think this is a great question. Unit testing, micro-testing, TDD, and BDD are difficult, sometimes confusing, and often not taken seriously. So kudos for trying and asking for help! I am by no means an expert, but I did just take a formal class and am also part of a small team that is leading an initiative to roll out unit testing and TDD within our ...


1

I tested the ORM for the Chicago Boss framework about a year ago. Instead of using unit tests I mostly used QuickCheck Properties, in which I created random data and saved it to the database, then read it back and made sure that I got the same thing back. It turns out that there was a problem (now fixed) in that if you saved a string that had the substring ...


3

So just for other PHP guys that may be struggling with functional programming I want to register here the steps I did following Jack's answer. First I refactored each method to extract the condition so I could have an identical code base in both (note how the condition was extracted in both): public function getKeysToInvalidateOnCreation($entity, $allKeys) ...


6

PHP isn't a language I have much experience with, but as I understand it both loops are trying to filter the set of keys, so you can extract the structure of the loop into another method that accepts the conditions for filtering as an argument in the form of a function: private function getKeysWhere($entity, $allKeys, $condition) { $result = []; ...



Top 50 recent answers are included