OpenCrowbar includes a Business Driven Development (BDD) framework written in Erlang that is based on the Cucumber DSL (Domain Specific Language).
The intent of these tests are to focus on the responses and requests to the web-interface and RESTful API.
Core BDD Commands:
test
- Runs the complete suitefeature
- Runs a single feature test filescenario
- Runs a single test from a feature filesteps
- Shows available steps already created when creating new scenarios
Note: The site you are trying to test MUST BE RUNNING!
cd /opt/dell/crowbar_framework/BDD
linux.sh
orWin7.bat
to compile the erlang code depending on your platform (may give an error; that's ok)erl
to start a command shell for erlangbdd:test().
will run all the tests and report the results. Test results are copied to a../tmp/bbd_results.out
with a date/time stamp so you can review test status (see failed() below).bdd:feature(name).
will run just the named feature set. You can pass the feature name as an atom or string.bdd:scenario(name, id).
will run just the scenario selected from the feature file. ID's are assigned by BDD based on a hash of the scenario name.bdd:debug(config, name, id).
will run just the scenario selected from the feature file with debug logging flags. ID's are assigned by BDD based on a hash of the scenario name.- You may also pass a list of the specific log levels requested. (if omitted,
debug
is assumed) - You can pass a single atom instead of a whole list of log levels:
trace
,debug
, andinfo
are supported.
- You may also pass a list of the specific log levels requested. (if omitted,
bdd:failed(config).
will rerun just the failed tests using the test results output file (../tmp/bbd_results.out
).bdd:steps().
will show you all the available step definitions
Note: You can run
bdd:test("profile").
orbdd:feature("profile","feature").
if you want to use an alternate profile thandefault
. Alternate profiles use the matching configuration name and had a different global setup/teardown location.The default tests run as the developer user; you must be in development mode to use them!
The BDD test results are reported using a condensed format:
- Feature name
- Total tests
- Passed tests
- Failed tests
- Skipped tests
- IDs of the failed tests
Each barclamp is expected to add its own tests to the suite. The OpenCrowbar barclamp tests include:
Test | Function |
---|---|
dashboard.feature | Tests the nodes UI view |
documentation.feature | Tests the documentation/help system |
navigation.feature | Tests the basic menu system Checks for localization omissions |
proposals.feature | Tests the Proposal Status API |
nodes.feature | Tests the node status API Tests the node detail page & API |
groups.feature | Tests the group API Tests the groups + nodes API |
scaffolds.feature | Tests all the feature objects |
authenticate.feature | Tests login |
users.feature | Tests user management screen |
attributes | Tests Jig attributes API |
jigs | Tests the Jig engine API |
The BDD system generates trace files for each test executed. These trace files have the results of all the steps for each scenario. If the test passes, the trace file is deleted automatically.
Reviewing the trace output on failed tests is the fastest way to determine if there is a problem with the system or the test because it will show you the page results that are being examined.
Note: Remember, if you change code then you must recompile (e.g.:
c(bdd).
) it!
Erlang is a functional language; you can run nearly any step if you can duplicate the input. Nearly every BDD method requires the Config list. The Config list contains critical information about the environment and session data based on a system login.
To create a Config list, use the start command with a configuration: bdd:start(default).
This command will load the selected config, start the http & auth services and finally get a session for access to the web site.
Note: The session will expire if it is not used! If the session expires, forget the values (
f(Cbase)
andf(Config).
).
Once you have a valid Config list, there are wide range of options. You can execute the global inspector using bdd:inspect(Config).
or one in each feature using node:inspector(Config).
To use the interactive debugger, you must:
- Compile the files using
show_debug
flag. For example,c(bdd, show_debug).
- Start the debugger using
debugger:start().
- Use the GUI to monitor the module and injection point desired
Note: The debugger is a little flaky. Have patience!
Since BDD works against a live system without rollback, BDD has added checks to make sure that tests to not leave testing artifacts in the database after a successful run.
To implement this capability, each object related feature is expected to implement an inspector
method that returns the current state of the objects that it will be acting on. These routines are called before and after the tests are run. If the list is different, then the BDD inspector will issue a warning and show the artifacts.
- The pre-run artificat list is saved at
../tmp/inspection.list
- To retrieve the last inspector report, use
bdd:is_clean(Config).
- To generate the list used for the inspector report, use
bdd:inspect(Config).