-
Notifications
You must be signed in to change notification settings - Fork 1
DbBot Usage Guide
Table of Contents
- Overview
- Configure and Run DbBot
-
Failbot
- What is FailBot
- FailBot Prerequisites
-
Run FailBot
- FailBot Options
- To run FailBot
- [To add a new section for FailBot reports] (#toaddnewsection)
- [Automated Regression Tests] (#regressiontests)
- Troubleshooting
Upon completion of Robot test suites, an output.xml file is generated that summarizes the results of the executed tests. This file is difficult to read and manipulate. DbBot MSSQL parses this output.xml file and writes the information into a SQL Server® database. You can then run reports and statistics on various test runs to investigate frequently failing tests and suites. Potentially, the DbBot can be used against any output.xml file generated by an up-to-date version of Robot.
* Python 2.7 installed * [pymssql](http://code.google.com/p/pymssql/) - pymssql is the Python language extension module that provides access to Microsoft SQL Servers from Python scripts Note: Pymssql installer requires a valid python entry in registry 1. Navigate to http://code.google.com/p/pymssql/downloads/list 2. Download and install [pymssql-2.0.0b1-dev-20130111.win32-py2.7.exe](http://code.google.com/p/pymssql/downloads/detail?name=pymssql-2.0.0b1-dev-20130111.win32-py2.7.exe) * Microsoft SQL Server® Database (tested with SQL Server® 2008) 1. Create an empty MSSQL Server Database [following these steps](http://msdn.microsoft.com/en-us/library/ms186312.aspx)-
Open
mssql_dbbot\dbbot\robot_database.py
in a text editor -
Locate the command to connect to the database, for example:
return pymssql.connect(host='sql.host.name', user='exampleuser', password='password', database='RobotDB')
-
Modify the database details to point to your database
-
Change the username and password to the appropriate values
-
Add the MSSQL directory to your PYTHONPATH environment variable. A valid PYTHONPATH could be:
C:\DbBot\mssql_dbbot
Option Strings | Description |
---|---|
-h, --help | Prints help instructions and lists these options |
-v, --verbose | Be verbose about the operation |
-d, --dry-run | Do everything except commit to database |
-k, --also-keywords | In addition, parse suites' and tests' keywords |
-c, --clear-database | Clear database of existing data before parsing |
-m, --log-messages | Parse and store messages; Requires keywords to be parsed |
-f, --files [output.xml files] | One or more Robot Framework output.xml files to parse |
- Open a command prompt window
- Navigate to your
mssql_dbbot
directory, For example:
cd c:\mssql_dbbot
- Perform the following command, changing the last option to point to your output.xml file:
python dbbot.py -f c:\output.xml
- Check that the values were loaded into the database specified in
mssql_dbbot\dbbot\robot_database.py
(see Configure Database Properties)
Option Strings | Description |
---|---|
-h, --help | Will print help instructions, and a list of these options |
-v, --verbose | Be verbose about the operation |
-o, --output | Path to the resulting html file |
-n, --name | Specify the report name / title |
- Navigate to the
mssql_dbbot
directory - From this directory, execute the following command:
python failbot\bin\failbot --name "[report title]" -o [path for output file]
Replacing [report title] and [path for output file] fields with appropriate values.
Your report should be generated and saved in the location you provided in [path for output file] parameter.
1. Navigate to ``failbot/failbot`` 2. Open the file ``database_reader.py`` for edit 3. Create a new function: 1. Copy and paste one of the existing functions from one of the existing sections - for example: def most_failed_tests(self):
sql_statement = '''
SELECT count(tests.id) as count, tests.name, suites.name, tests.id
FROM tests, test_status, suites
WHERE tests.id = test_status.test_id
AND tests.suite_id = suites.id
AND test_status.status = 'FAIL'
GROUP BY tests.name, tests.suite_id, tests.id, suites.name
ORDER BY count DESC
'''
return self._fetch_by(sql_statement)
-
Change the function name to something more appropriate
-
Change the SQL statement stored in the sql_statement variable to the query you wish to execute
-
Update the HTML writing functionality:
-
Open
failbot/html_writer.py
in a text editor or an IDE -
Find the produce function, which aggregates information from various sections of the database:
def produce(self): self._verbose('- Producing summaries from database') output_html = self._full_layout.substitute({ 'page_title': self._report_title, 'time_stamp': self._return_time_string(), 'most_failed_suites': self._table_of_most_failed_suites(), 'most_failed_tests': self._table_of_most_failed_tests(), 'most_failed_keywords': self._table_of_most_failed_keywords() })
-
Add a line to the output_html variable using one of the 'most_*' lines as an example
-
Create a new function for formatting your new table using an existing one as an example:
def _table_of_most_failed_tests(self): return self._format_three_column_table_with_suite_name(self._db.most_failed_tests())
Choose between _format_three_column_table_with_suite_name and _format_two_column_table_with_suite_name, depending on the number of attributes to display - two or three, respectively.
The automated regression suite provided with DbBot is written in the Robot Framework. It runs the DbBot with various types of test output.xml files.
- Robot Framework
The regression suite is located in: mssql_dbbot/Testdbbot
.
- Open
mssql_dbbot\dbbot\robot_database.py
in a text editor - Locate the command to connect to the database, for example:
return pymssql.connect(host='sql.host.name', user='exampleuser', password='password', database='RobotDB')
- Modify the database details to point to your test database (so as not to affect your actual results)
- Navigate to
mssql_dbbot/Testdbbot
- Execute the following command:
pybot Testdbbot/DbBot_Output_Tests.txt
The test output.xml files used are stored in the testdata
directory.
-
Save the output.xml you wish to test to
testdata/<name of tested area>
for example:testdata/large_xml/test_output.xml
-
Open
Testdbbot\DbBot_Output_Tests.txt
in a text editor -
Create a new Test Case with the following format:
<<Your Test Case Name>> [Documentation] Input large output file containing 20,000 tests ${console_output} = Console Output For Output File in Sub-Directory <<name of the dir your created in the previous steps>> Database Commit Should Have Succeeded ${console_output}
Note: The final keyword can be replaced with a keyword to check for a parse error -- if this test is expected to fail:
Parse Error Should Be Present ${console_output}
- Output.xml files that have been generated from two output.xml files, which have been combined with Robot, cannot be processed by DbBot -- automated regression test currently fails.
- Update your MSSQL-DbBot to the latest version
- Delete your existing 'test_run_errors' table (MSSQL-DbBot will recreate it)