# TestClass1 \< TestClass0 \< Test::Unit::TestCase

**URL:** <https://www.ruby-forum.com/t/testclass1-testclass0-test-testcase/150324>\
**Category:** Ruby\
**Created:** [October 7, 2008, 11:32am UTC](https://www.ruby-forum.com/t/testclass1-testclass0-test-testcase/150324 "2008-10-07T11:32:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emilsverige](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@emilsverige](https://www.ruby-forum.com/u/emilsverige)\
**Post date:** [October 7, 2008, 11:32am UTC](https://www.ruby-forum.com/t/testclass1-testclass0-test-testcase/150324/1 "2008-10-07T11:32:11Z")

</div>

Hi,  
I have a test class, TestClass0, with a few test methods. I specify some  
hard coded values in the setup method:

# test\_class0.rb

require ‘test/unit’  
class TestClass0 \< Test::Unit::TestCase  
def setup  
@server\_url = “[http://localhost:8080](http://localhost:8080)”  
end

def test\_something\_with\_watir  
# …  
end

def test\_something\_else\_with\_watir  
# …  
end  
end

# test\_class1.rb

require ‘test/test\_class0’  
class TestClass1 \< TestClass0  
def setup  
@server\_url = “http://my\_test\_server:8080”  
end  
end

I want to run the exact same tests with slightly different values,  
therefor I extend the class, override setup with the different values.

The problem is the line: “require ‘test/test\_class0’”  
It first runs all the tests specified in TestClass0, with the  
@server\_url specified in TestClass0. When they are completed the same  
tests are run with the server url specified in TestClass1. How could i  
skip the first tests, only run the tests with the @server\_url from  
TestClass1?

---

<div class="post-metadata">

**Author:** ![emilsverige](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@emilsverige](https://www.ruby-forum.com/u/emilsverige)\
**Post date:** [October 7, 2008, 11:44am UTC](https://www.ruby-forum.com/t/testclass1-testclass0-test-testcase/150324/2 "2008-10-07T11:44:32Z")

</div>

Hmm, you’re probably right. I’m gonna have to think about it.

---

<div class="post-metadata">

**Author:** ![emilsverige](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@emilsverige](https://www.ruby-forum.com/u/emilsverige)\
**Post date:** [October 7, 2008, 11:37am UTC](https://www.ruby-forum.com/t/testclass1-testclass0-test-testcase/150324/3 "2008-10-07T11:37:28Z")

</div>

2008/10/7 Emil S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> require ‘test/test\_class0’  
> It first runs all the tests specified in TestClass0, with the  
> @server\_url specified in TestClass0. When they are completed the same  
> tests are run with the server url specified in TestClass1. How could i  
> skip the first tests, only run the tests with the @server\_url from  
> TestClass1?

I’d choose a completely different pattern: the URL should be part of  
some kind of configuration information that you provide instead of  
being hard coded in the test case. You could

- have it in an environment variable
- in the command line
- in a config file (probably ~/.your\_test\_rc or such)

Cheers

robert
