Timeline for How to test local/nested conditional logic branches and variables that cannot be easily manipulated?
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 21, 2017 at 11:46 | vote | accept | user58446 | ||
| Mar 20, 2017 at 21:29 | history | tweeted | twitter.com/StackSoftEng/status/843937620870795265 | ||
| Mar 20, 2017 at 14:15 | answer | added | Radu Murzea | timeline score: 0 | |
| Mar 20, 2017 at 12:21 | answer | added | Eternal21 | timeline score: 5 | |
| Mar 18, 2017 at 23:49 | comment | added | John Wu | Depends on the language I guess. In c#, it is certainly possible using fakes. See this answer for an example of swapping out DateTime.Now with your own shim. | |
| Mar 18, 2017 at 23:36 | answer | added | Doc Brown | timeline score: 0 | |
| Mar 18, 2017 at 21:52 | comment | added | user58446 | This question has some information but indicates it is not necessary for unit-testing. Not sure how this could be in the example I gave. | |
| Mar 18, 2017 at 21:50 | comment | added | user58446 | Your comment seems to be the answer. I have read a little about dependency injection, but it seems to be used for various things and I am having trouble relating the specifics to what I am trying to do (unit-testing). I could not find much on autowiring (only related to Spring). Can you post an answer explaining these two concepts with some good examples of how they can be used to unit-test... or direct me to a SO question that does. My terminology is weak, so searches are coming up blank. | |
| Mar 18, 2017 at 21:26 | comment | added | Kilian Foth | You can't. That's why people are so obsessed about autowiring and dependency injection: if your time provider or your database handler were non-hardwired, you could easily mock it for testing without changing the source. As it is, you have to essentially wait until Monday to run the test, which is a Really Bad Thing. | |
| Mar 18, 2017 at 20:34 | history | asked | user58446 | CC BY-SA 3.0 |