# Detect test cases are currently running

**URL:** <https://www.ruby-forum.com/t/detect-test-cases-are-currently-running/137860>\
**Category:** Deployment\
**Created:** [May 17, 2008, 12:10am UTC](https://www.ruby-forum.com/t/detect-test-cases-are-currently-running/137860 "2008-05-17T00:10:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [May 17, 2008, 12:10am UTC](https://www.ruby-forum.com/t/detect-test-cases-are-currently-running/137860/1 "2008-05-17T00:10:46Z")

</div>

How do I know in my code that Im in the middle of running test cases.

I thought there was a “$TESTING” variable that I could check but that  
one is always empty.

I would like to be able to know whether or not to load in test helpers  
in the init.rb files of plugins.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [May 17, 2008, 12:21am UTC](https://www.ruby-forum.com/t/detect-test-cases-are-currently-running/137860/2 "2008-05-17T00:21:07Z")

</div>

You can always just set $TESTING=true in your test\_helper file and use  
it that way.

-Ezra

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [May 17, 2008, 12:25am UTC](https://www.ruby-forum.com/t/detect-test-cases-are-currently-running/137860/3 "2008-05-17T00:25:49Z")

</div>

You can compare the RAILS\_ENV constant. If it is “test”, then you’re  
running tests.

RAILS\_ENV == “test”

- Jamis
