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

Similar Threads

Gather autocompletion-information while running tests? 1
Python Unit Tests 10
Parallel scaalability tests... 0
PWM Issues 0
Functional tests 0
Aborting unit tests 0
List tests with test/unit 0
Creating unit tests on the fly 3

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top