Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passes manual testing, but automated testing returns "NoSuchElementException: No Line Found" #36

Closed
bokwoon95 opened this issue Sep 12, 2017 · 3 comments

Comments

@bokwoon95
Copy link

Here's the relevant PR: https://github.com/nus-cs2103-AY1718S1/addressbook-level2/pull/400

I made an enhancement that prompts the user for name, phone, email, address & tags one by one as shown below. This passes manual testing, however it returns “NoSuchElementException: No line found” if I use file redirection with input.txt instead.
screen shot 2017-09-12 at 1 07 56 pm
the compile error
screen shot 2017-09-12 at 1 17 17 pm

Here's what input.txt looks like:
screen shot 2017-09-12 at 1 29 39 pm

Seems like it's something to do with Scanner.nextLine() not detecting a next line, but nextLine() is the only way to read in strings with spaces in them. Any idea what is causing this?

@damithc
Copy link
Contributor

damithc commented Sep 12, 2017

When using the I/O method of testing, you should not create multiple scanners. Reason: all input text (given in one shot via the file) is swallowed by the first Scanner, leaving nothing for the subsequent scanners.

@damithc
Copy link
Contributor

damithc commented Sep 12, 2017

On a general note, the current code is tailored for a CLI interface where each command is stand-alone. Prompting for user input is hard to fit into the current code base, unless you put the code somewhere it doesn't belong, such as what you have done. :-p i.e. Interacting with the user should not be done in one place rather than all over the code base.
EDIT: should not be -> should not be

@bokwoon95
Copy link
Author

Oh yeah I tried to get the existing system to accept user inputs one by one, but found it too complicated to modify (hence the cheap hack with creating a new class to tack onto the existing 'add person' method).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants