Can FitNesse page tags be used in page? - fitnesse

Is there a way in FitNesse to access page tags from inside the page?
I need to change database connection strings at test start-up and would like to use a tag as a switch.

I would recommend that you create multiple top level suites, one for each environment (e.g. one for testing locally and one for Azure) that defines the environment specific settings using wiki symbols (i.e. !define ...). The tests that are to be executed in all environments can be defined is separate suite that is included in each environment's suite using a symbolic link. The tests in the shared suites use the wiki symbols to get the values for the environment they are included in.
This makes it explicit which settings are different between each environment
All different environments are visible in the wiki
Adding or removing an environment setting requires no (fixture) code changes
You can add environment specific tests for each environment (just add them to the environment's suite besides the shared tests included via symbolic link)

Related

Different environments included in Ruby on Rails

Can someone explain to me what the Rails environments are and what they do? I have tried researching myself, but could not find anything. From what I gather, the environments are:
Development
Productions
Test
Each "environment" is really just a config. You can launch your app in various different modes, and the modes are called "environments" because they affect the app's behaviour in lots of different ways. Ultimately, though, they are just configs.
BTW you can't have looked very hard when you looked "everywhere", because i just googled "rails environment" and the top result was this
http://guides.rubyonrails.org/configuring.html
which is the official explanation of configuring the rails environment.
From what you have provided in your question, it seems that you are asking:
"What are the difference between each environment configuration in Rails?"
Rails comes packages with 3 types of environments. Each have its own server, database, and configuration. See Rails Guides: Configuration for more information on options available to you.
Setting up the environment
To set your Rails environment, you will want to enter in command line:
export RAILS_ENV=<env>
Where <env> can be test, development, or production. Setting this environment variable is crucial, as it will determine what gems are installed, or what env is touched when running rails console or rails server.
Included in configuration is the gemset used for the app. When you run rails new, you will find a Gemfile with groups test, development, and production. These groups correspond to the environment currently set. When the environment is set to one of those, running bundle install installs all gems related to that group (and gems not listed in a group).
Included environments
test is designed for running tests/specs. This database will likely be bare bones, except for seeds you may call before running the suite. After each test is complete, the database will rollback to its state before the test began. I do not recommend launching rails server, as running tests (via MiniTest or RSpec) will do this for you, and close the server once the suite is finished.
development allows you to "test" your app with a larger database, typically a clone of production. This allows you to test actual real-world data without breaking production (the version that customers or end-users will experience). To view the development environment in action, change the RAILS_ENV and launch rails server. This is good for deciding how you want your pages to look (CSS, HTML). It is also good practice to briefly "test" your app yourself, clicking around making sure everything "looks" good and the JavaScript works.
production is reserved for the customer and end-user. Configuration includes the actual domain of the app, which ports to use, and initializers or tasks to run. You do not want to play around with your database, as it may be customer-impacting. Ideally, the app should work as best as it can, since this is considered your "final product."
Here are some good reads about Rails Environments
http://teotti.com/use-of-rails-environments/
and
https://signalvnoise.com/posts/3535-beyond-the-default-rails-environments
good luck !!

Rails: Make request to development environment while using tests

I would like to know how I could make a request on my development environment from the tests environment.
I know it's not a good practice but I don't know how to achieve my goal otherwise:
On my project, I've created some modules (Newsletter, Search, GuestBook, ...) and I would like to have a table allowing me to enabled or disabled modules. I have created the scaffold for this.
The but of all of this is to not run tests if the setting is disabled in other environments.
My problem is when I make a request to check if the module is enabled or not, it targets the test database and not the development database.
Anyone know how I could solve my problem ?
Thanks for your help
You don't want to do it that way, you want to set the same DB in your test environment so that it will check that table in your test DB during the testing.
...or even better, stub out the model used to retrieve those enabled/disabled settings so you can just adjust them on the fly as you run various tests.

Why Grails unit, integration and functional test phases do not have their own environment?

Unit test don't need a database.
Integration and functional tests can have different fixtures and bootstrap data.
It would be also better to split functional tests on application itself and Selenium testing robot.
So, is there any reason to keep all tests phases in one environment?
I guess that's just a convention, since:
The setup of the unit tests configure a memory database to let you use GORM methods.
Your database will be initialized only when running integration tests.
Functional tests are treated as extension and depending on your project they're not mandated (for example: plugin projects that does not rely on UI).
Nothing stops you to define custom environments and run specific commands to them. You can also create Spring Beans and configure database access according to your env, using the Environment class.
if(Environment.current == Environment.DEVELOPMENT) {
...
}

Creating a rails testing dashboard in a non-test environment

I want to create an online admin dashboard which will indicate whether our most important tests are passing. I've already written the tests, but how I could run them on demand and see what their results are in a non-test (production) environment?
I'd like to avoid rewriting the test code if possible.
I have 3 ideas for how to do this (not sure if they're any good):
Using system calls to grep the verbose (-v) output of the tests
Use a different test_runner that will give easier to parse ouptut via system call
Somehow abstract the testing functions so that they can be used in a non-test context. (Not sure how I would do this..

Use Ruby on Rails environment config based on URL/Machine Name

I have a RoR3 app with multiple environment configs, development.rb, test.rb and production.rb.
Is there a way I can instruct the application to used a specific config based on a value in the URL or machine name??
For instance if the machine name contains "dev", then use development.rb.
Edit
If that is not possible, is there a way I can access the request URL from the application.rb or environment.rb files maybe. If so, I could probably use a regex on the URL to determine and set the environment settings dynamically within if blocks.
In the end, we'll end up having many more than just 3 environments, all with certain differences. So I need a very flexible way to set the config.
Probably not. By the time the rails app is running (and can look at the machine name) it's already picked an environment. Unless you hack the boot script...
It'd be much easier to just put the environment into the startup-command-line for each machine.

Resources