Commit a5b5bb28 authored by Yan Couto's avatar Yan Couto

Adding more documentation to tests

parent 52978a59
## Creating tests
# Tests
To create a test, just create a `.rb` file. It should finish normally if the test passed, and end with `exit 1` otherwise, preferably explaining why the test failed.
## Why to run the tests
## Running tests
Running these tests will make sure that crew is working correctly, or explain the problem if it's not.
Just run the `test_all` file. Running tests manually may not work!
## When to run tests
The tests can be used at any time to help with developing, but make sure to run them before submitting a Pull Request.
## How to run the tests
Execute `ruby test_all`. If all tests pass, it will print `All tests successful.`, otherwise it will show what went wrong.
Running tests manually may not work!
## Preparing new tests
To prepare a new test, create a `.rb` file. It may use crew constants (created in `lib/const.rb`) and import packages (be sure to use `require_relative`).
It should finish normally if the test passed, or finish with `exit 1` otherwise, preferably explaining why the test failed.
All `.rb` files in this directory will automatically be run by the `all_tests` script.
Here is a simple example of a test:
```ruby
# Makes sure buildessential package depends on gcc
require_relative("../packages/buildessential")
pkg = Object.const_get('Buildessential')
if pkg.dependencies and pkg.dependencies.has_key?('gcc') then
puts "Everything works properly.".lightgreen
else
puts "Buildessential should depend on gcc!".lightred
end
```
# This test checks whether the packages create a dependency cycle.
require 'find'
require_relative '../lib/color'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment