# How to run test unit in controller

**URL:** <https://www.ruby-forum.com/t/how-to-run-test-unit-in-controller/157458>\
**Category:** Rails\
**Created:** [January 11, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/how-to-run-test-unit-in-controller/157458 "2009-01-11T17:29:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 11, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/how-to-run-test-unit-in-controller/157458/1 "2009-01-11T17:29:26Z")

</div>

Hai Guys…  
I need help…  
I want to run test:unit in controller and the result will show on  
view…  
Any body can help me???

–  
Wu You Duan

---

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 11, 2009, 5:56pm UTC](https://www.ruby-forum.com/t/how-to-run-test-unit-in-controller/157458/2 "2009-01-11T17:56:29Z")

</div>

anton effendi wrote:

> I want to run test:unit in controller and the result will show on  
> view… Any body can help me???

> Wu You Duan

(BTW which one are you?)

You can run a script from the view like this:

```
<%=h `rake test:units` %>
```

However, why would you do such a thing? Unit tests should run while you  
edit,  
before you manually test in development mode, and way before production  
mode.

–  
Phlip

---

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [January 12, 2009, 2:48am UTC](https://www.ruby-forum.com/t/how-to-run-test-unit-in-controller/157458/3 "2009-01-12T02:48:02Z")

</div>

I want to make monitoring 1 site…  
I don’t have idea about it… so I think that is idea for solve…

do you have idea???

On Sun, Jan 11, 2009 at 11:55 PM, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You can run a script from the view like this:
> 
> >

–  
Wu You Duan

---

<div class="post-metadata">

**Author:** ![anton\_effendi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@anton\_effendi](https://www.ruby-forum.com/u/anton_effendi)\
**Post date:** [February 7, 2009, 1:33pm UTC](https://www.ruby-forum.com/t/how-to-run-test-unit-in-controller/157458/4 "2009-02-07T13:33:19Z")

</div>

Here’s a reason for running tests from a controller: Testing the  
implementation of a 3rd party API.

I have a Rails app that sends RESTful requests to a third party who is  
implementing the interface. The third party may or may not be using  
Rails. I want to allow the third party to run our test suite and have  
access to the test results so that they can verify their  
implementation.

I haven’t implemented the interface yet, but this is a step in the  
right direction for me.

Brian
