Creating tests

D

Druhie Almighty

Hi!
I guess, my problem will scarcely take you very long :)
Recently I faced with a trouble connected with creating the tests for my
program. It usually occured to be sufficient to use the methods within
the class I was testing and compare the rusult with the neccesary value
of variable or method which is used for variable. But for the current
program I need a test that would simulate the input.
In other words, for an instance let us have the following 'program':

###
a=0
puts("answer is #{a+=gets.to_f}") while true
###

The test must input the numbers sequently and assert the equality of the
actual output with the necessary string after each step of the cycle.
So, could you please give me an example of how such tests are supposed
to be written?
I'd be very thankful for your help!
 
J

Jari Williamsson

Druhie said:
Hi!
I guess, my problem will scarcely take you very long :)
Recently I faced with a trouble connected with creating the tests for my
program. It usually occured to be sufficient to use the methods within
the class I was testing and compare the rusult with the neccesary value
of variable or method which is used for variable. But for the current
program I need a test that would simulate the input.
In other words, for an instance let us have the following 'program':

###
a=0
puts("answer is #{a+=gets.to_f}") while true
###

The test must input the numbers sequently and assert the equality of the
actual output with the necessary string after each step of the cycle.
So, could you please give me an example of how such tests are supposed
to be written?
I'd be very thankful for your help!

Unless I haven't misunderstood something: Overwrite gets() so it outputs
the required user simulation, either on system level, class level or
instance level.


Best regards,

Jari Williamsson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top