Skip to content

rschultheis/tcfg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCFG

TCFG (pronounced "tee config") is test suite configuration for the real world. TCFG offers:

  • Support for easily controlling which environment your tests execute against

  • A tiered structure to configuration which allows for every kind of configuration scenario to be supported.

  • Support for easily integrating standalone test suites into common Continuous Integration platforms like Jenkins.

Background

The Wiki contains more in depth information. Some good places to start:

Getting started

Using in RSpec

Start by installing the gem:

$ gem install tcfg

In the project root, make a yaml file called tcfg.yml that contains all configuration you want to be able to control. For a selenium suite, it might look something like this:

---
#start with basic defaults
BROWSER: firefox
BASE_URL: http://localhost:8080
LOG_LEVEL: INFO

#This is a special section with overrides by 'environment'
t_environments:
  QA:
    BASE_URL: http://qa.mysite.com

  Production:
    BASE_URL: https://mysite.com

Then configure RSpec to use tcfg in your spec helper file (typically called spec/spec_helper.rb):

require 'tcfg'

RSpec.configure do |config|
  config.include TCFG::Helper
end

Now you can access configuration in any before, after, or it block, like:

require 'selenium-webdriver'
RSpec.configure do |config|
  config.before(:all) do
    @browser = Selenium::WebDriver.for tcfg['BROWSER']
  end

  config.before(:each) do
    @browser.get tcfg['BASE_URL']
  end

end

If you need to access configuration outside of a before, after, or it block you can use the TCFG module directly:

Log.level = TCFG['LOG_LEVEL']

To control your test suite, you can use environment variables. To change the browser used:

#To execute with all default configuration
$ rspec

#To change the browser used
$ T_BROWSER=chrome rspec

#To change which environment the tests execute against:
$ T_ENVIRONMENT=QA rspec

Other uses

TCFG is a general purpose configuration framework. It should be possible to use with most Ruby test frameworks or even for non testing uses. If you have a use and aren't sure how to handle it with tcfg, file an issue we'll see if we can help you out.

Examples

TCFG is used in several projects that demonstrate it's capabilities.

About

test suite configuration for the real world

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages