From: Phlip Date: 2007-11-04T09:00:14+09:00 Subject: Re: How do you write a unit test of methods that needs user inpu pood.forums wrote: > Will I need to change my code or is there a way for me to write my unit > test that automatically enters some inputs? Get with Mocha, a mock-object library. Then mock the method that returns user input, and put whatever the test needs into it. > Idealy, I'd like to do it so that when I run my unit test, It'll ask me > for the inputs. Right now it just goes thru the code without asking me > for the inputs. Okay, this is different. If it's interative, it's not an automated test. If you to test many different inputs, put them into a table and loop over the table each time you test. Make the table easy to edit, such as a YAML file. See "FIT" and "Fitnesse" for good GUIs on these tables of test data. Then invent your own, Ruby-style, without devolving into FIT's sounce code! -- Phlip