[Israel.pm] problem with a test

moshe nahmias moshegrey at ubuntu.com
Thu Dec 27 12:39:10 PST 2012


Hi,
OK, I solved it and you gave me the idea :)
The problem was that when I gave the file the program thought it as a
parameter and didn't know what to do with it, while waiting for user input
because of <>. So I thought may be if I will add an open file it will know
what to do and it solved the problem.

The only thing I don't get is why then did it work if I use the full
program? Why the test doesn't work as the program or vice versa?

On Thu, Dec 27, 2012 at 10:47 AM, sawyer x <xsawyerx at gmail.com> wrote:

> On Thu, Dec 27, 2012 at 12:43 AM, moshe nahmias <moshegrey at ubuntu.com>wrote:
>
>>
>> Hi,
>> As you know I write the mail stats program and started to write tests for
>> it while I try to make it OO so nothing will break.
>>
>
> Awesome! That's a great reason to write tests!
>
>
>> But...
>> I wrote the input tests and there is a problem there, the last test which
>> is supposed to get the data from the user via a file don't work well.
>> It waits for a user input (even though only on the test and not while
>> running the program, and using the same file for testing and when checking
>> through the program).
>>
>
> I think you should separate getting the input from the user, and using
> that input to do something.
> That way you can test what needs to be done without checking input from
> the user.
> You could also check the "getting input from user" subroutine separately
> and easily.
>
>
>> I would like to know why it works on the full program but not on the test
>> (isn't it supposed to be the same in this case?).
>>
>
> If I recall yesterday, you described the reason above. In the first test
> you had you were not entering the input reading (my $input = <>), and on
> the second test you were entering it, so it was hanging, waiting for input.
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20121227/454f64c9/attachment.htm 


More information about the Perl mailing list