# Rcov: how to write test cases

**URL:** <https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892>\
**Category:** Rails\
**Created:** [February 7, 2009, 7:12am UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892 "2009-02-07T07:12:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brijesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@brijesh](https://www.ruby-forum.com/u/brijesh)\
**Post date:** [February 7, 2009, 7:12am UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892/1 "2009-02-07T07:12:11Z")

</div>

Hi I am using rcov to generate code coverage. But I don’t know how to  
write cases for that…

I have installed rcov gem and and execute rcov test/\*.rb command. It  
shows me some code coverage in files.

Can anyone help me by giving example that how to write test cases and  
where to write…

Thanks in advance…

---

<div class="post-metadata">

**Author:** ![brijesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@brijesh](https://www.ruby-forum.com/u/brijesh)\
**Post date:** [February 7, 2009, 7:31am UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892/2 "2009-02-07T07:31:32Z")

</div>

Brijesh S. wrote:

> Hi I am using rcov to generate code coverage. But I don’t know how to  
> write cases for that…
> 
> I have installed rcov gem and and execute rcov test/\*.rb command. It  
> shows me some code coverage in files.
> 
> Can anyone help me by giving example that how to write test cases and  
> where to write…
> 
> Thanks in advance…

[http://thelucid.com/2007/08/24/using-rcov-to-measure-the-test-coverage-of-rails-plugins/](http://thelucid.com/2007/08/24/using-rcov-to-measure-the-test-coverage-of-rails-plugins/)

[http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-4-rcov-and-more-behavior-driven-development/](http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-4-rcov-and-more-behavior-driven-development/)

---

<div class="post-metadata">

**Author:** ![brijesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@brijesh](https://www.ruby-forum.com/u/brijesh)\
**Post date:** [February 7, 2009, 8:51am UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892/3 "2009-02-07T08:51:10Z")

</div>

Dharmdip R. wrote:

> Brijesh S. wrote:
> 
> > Hi I am using rcov to generate code coverage. But I don’t know how to  
> > write cases for that…
> > 
> > I have installed rcov gem and and execute rcov test/\*.rb command. It  
> > shows me some code coverage in files.
> > 
> > Can anyone help me by giving example that how to write test cases and  
> > where to write…
> > 
> > Thanks in advance…
> 
> [http://thelucid.com/2007/08/24/using-rcov-to-measure-the-test-coverage-of-rails-plugins/](http://thelucid.com/2007/08/24/using-rcov-to-measure-the-test-coverage-of-rails-plugins/)  
> brijesh

> [http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-4-rcov-and-more-behavior-driven-development/](http://www.ultrasaurus.com/sarahblog/2008/12/rails-2-day-4-rcov-and-more-behavior-driven-development/)

Thanks I know this… but I am not getting how to write test cases  
which will related to our definition…

lets take example: test cases for create method in user model which  
check validations …

---

<div class="post-metadata">

**Author:** ![brijesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@brijesh](https://www.ruby-forum.com/u/brijesh)\
**Post date:** [February 7, 2009, 10:32am UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892/4 "2009-02-07T10:32:06Z")

</div>

You did not get my point…

I am not getting how to create test cases in test files…like in  
test/unit/.rb files…

[http://pastie.org/378498](http://pastie.org/378498)

require File.dirname( **FILE** ) + ‘/test\_helper’

class UserTest \< ActiveSupport::TestCase

# Replace this with your real tests.

def test\_should\_create\_user  
???  
end  
end  
end

what should be write in particular definition and how it will work? so i  
can generate other test cases…

Thanks

---

<div class="post-metadata">

**Author:** ![brijesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@brijesh](https://www.ruby-forum.com/u/brijesh)\
**Post date:** [February 7, 2009, 1:41pm UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892/5 "2009-02-07T13:41:40Z")

</div>

will call u

---

<div class="post-metadata">

**Author:** ![brijesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@brijesh](https://www.ruby-forum.com/u/brijesh)\
**Post date:** [February 7, 2009, 10:13am UTC](https://www.ruby-forum.com/t/rcov-how-to-write-test-cases/196892/6 "2009-02-07T10:13:17Z")

</div>

implementation of  
[http://morshed-alam.blogspot.com/2008/09/implementation-of-cruisecontrolrb-and.html](http://morshed-alam.blogspot.com/2008/09/implementation-of-cruisecontrolrb-and.html)
