Testing in Ruby
Initially, I would like to share about testing in Ruby.
First, I will suppose we have already known about ruby and
have already installed ruby environments.
Now, We will create a Calculator class. This class will be simple:
And, now We will add about test class. Initially we’ll put test class under same directory.
Our test class will look like this:
And, we’ll run test code from terminal shell.
ruby -I . test_add.rb
Of course, test fails. Result will look like this:
Now We’ll fix at our calculator class.
And, we’ll run test code again( note: Our calculator doesn’t anything yet). It will shows like that:
We’ll fix calculator code again and will test again:
Note that: you’ll see a simple ‘.’ in the outputs of test result.
a ‘.’ intends for each test that passes meaning we can scan quickly.
Get Swe Swe Mar Soe’s stories in your inbox
Join Medium for free to get updates from this writer.
Now, we’ll add second test code.
Second test will run again:
Now, you will see “..” in results. A “..” means two tasks.
That’s all. I hope my topic makes you be helpful.
I would appreciate hearings about your thoughts and opinion on my story. Thank you all reading.
source link: https://github.com/swesweucsy/unit_test_ruby







