Timeline for answer to Python 3 unittest simulate user input by Ionuț G. Stan
Current License: CC BY-SA 2.5
Post Revisions
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 26, 2009 at 9:29 | history | edited | Ionuț G. Stan | CC BY-SA 2.5 |
deleted 2 characters in body
|
| Aug 25, 2009 at 16:19 | comment | added | Nick Bastin | @S.Lott: I'm not sure why you think the code that calls the standard library input call doesn't need to be tested. Yes, in this super trivial case, that code might just call input and call your foo(input) method, but many instances of user interaction aren't that simple. (And you obviously still need to be testing that code through some way of manipulating the UI). | |
| Aug 25, 2009 at 16:12 | comment | added | S.Lott |
@Nick Bastin: "Maybe, but somewhere, someone is gathering that input. When you want to test the method doing that..." The foo(input) does that. There is no "somewhere" else that this needs to be tested.
|
|
| Aug 25, 2009 at 16:08 | comment | added | Ionuț G. Stan | Nick, if the system under test is a legacy application, in which refactoring is very hard or it takes some time to do it, but you really want to have some characterization tests (which will actually support refactoring), then yes, I'd use your method. But, if the application is under development, it should be refactored so that unit tests are easy to write. | |
| Aug 25, 2009 at 16:04 | comment | added | Nick Bastin | Maybe, but somewhere, someone is gathering that input. When you want to test the method doing that, you'll have to either resort to functional testing tools that manipulate a UI to test at that level, or do some injection. Of course, you should also do functional testing that manipulates the UI, but that should be used just to test the UI (e.g. that input() takes the input you provided) and not have failures bleed into the land of non-UI implementation details. | |
| Aug 25, 2009 at 16:00 | history | answered | Ionuț G. Stan | CC BY-SA 2.5 |