Skip to main content

Timeline for How to unit test a top level method

Current License: CC BY-SA 3.0

13 events
when toggle format what by license comment
Aug 5, 2019 at 15:01 vote accept DanielS
Feb 5, 2018 at 22:45 comment added Dirk Herrmann Your tests would only be integration tests if you design them to specifically test the interaction between the components. If, in contrast, your tests are meant to check the algorithm of Matchall, they are no integration tests. Or, in other words: if for the goal of the test it is irrelevant whether or not you use the real depended-on-component or a double (mock, stub, whatever), then it can not be an integration test.
Feb 5, 2018 at 22:38 comment added Dirk Herrmann To add to Jeroen's good point: You could create some helper functions for your test to simplify creation of teams and rankings for your tests. Then the seemingly huge effort for setting up the fixture of each test may turn out quite manageable.
Apr 17, 2015 at 16:41 comment added Dunk Jeroen's comment is what I would say, with this addition. It seems like an integration test because you are doing an integration test by the strictest definition. You are integrating with the Team and Candidate classes. However, that's the route most people would probably take. The other route would be to mock your Team and Candidate classes in order to give yourself very explicit control of the results, but I don't know how that might help you because Team and Candidate seem so trivial.
Apr 16, 2015 at 21:33 history edited user40980 CC BY-SA 3.0
Fix / convert to markdown. Remvoe intro. Remove 'thanks in advance'. Remove 'edit' (there's a revision history)
Apr 16, 2015 at 21:29 history edited DanielS CC BY-SA 3.0
Added explanation and test case example
Apr 16, 2015 at 14:16 answer added Mike Nakis timeline score: 2
Apr 16, 2015 at 13:26 comment added Jeroen Vannevel It's unclear to me what's unclear to you. You inject a couple of teams and rankings, determine beforehand what result should be returned and verify that it is in fact returned. Then you write another test for two teams that result in an equal match and verify equality returns the correct result. Do this for each distinct scenario. Can you specify what you're having trouble with?
Apr 16, 2015 at 13:19 comment added MetaFight Although Tim's answer probably isn't sufficient, it is a nice exercise suggestion.
Apr 16, 2015 at 13:11 history edited Kilian Foth CC BY-SA 3.0
fix spelling
Apr 16, 2015 at 13:10 review First posts
Apr 16, 2015 at 15:05
Apr 16, 2015 at 13:10 comment added Tim Delete the function, write a failing test, then write the function again following strict TDD. Even if it's just an exercise, it will force you to write testable code.
Apr 16, 2015 at 13:04 history asked DanielS CC BY-SA 3.0