Testing MS Excel Data
We have a new provider for testing MS Excel data:
Excel@2. It is a preview, anything may change. Main advantages of the new provider are:
it does not need any prerequisites, it comes with CAT out-of-the-box
it allows you to run advanced SQL queries against MS Excel sheets
it uses cool and maintained technology under the hood
it will help us to port CAT to Linux in the future.
Data Sources: - Name: Departures Provider: Excel@2 Connection string: Departures.xlsx Sheets: Sheet1 Tests: - Name: Average number of passengers check Description: Average number of passengers is within the expected limit First Data Source: Departures First Query: | SELECT CASE WHEN AVG(PASSENGERS) BETWEEN 100 AND 150 THEN 'OK' ELSE 'KO' END FROM Departures.Sheet1 -- use DataSourceName.SheetName here WHERE DATE_OF_FLIGHT between today() and (today() + 7) Second Data Source: Departures Second Query: | SELECT 'OK' Expectation: sets match
You have to specify what sheets you want to test (the others are ignored). Notice the example uses constructs like aggregate functions,
CASE WHEN and date functions.
The older providers
ExcelOleDB@1 are still supported.
Executing Tests in Parallel
In previous releases, CAT was executing tests one by one. It did not start evaluation of a new test until the previous one was completely finished. This is still the default behavior of CAT.
However, if you decide it is useful to split the running of the tests into more parallel threads running at the same time, you now have the option.
Just put this to your project file:
# multithreading settings: Threads: 3
The setting must be in the root of the project file - there must be no whitespace before the keyword. In the example above, CAT will create three parallel running threads. You don’t have an option to specify what test is processed in what thread, they just take unexecuted tests from a queue and process them, like three cats drinking from one bowl.
Example Database, CAT Examples
We created a sample database of a fictious airport company. It is a simple one, it is easy to understand and we’ll use it for examples how to use CAT. You can get it from our GitHub:
There is one more repository, with complete examples of how to use CAT:
The latter is still work in progress, we’ll announce it soon.
SqlServer@1 provider timed out always after 30 seconds. Now, by default, there is no timeout, unless you manually set it.
Tests: - Name: Some long running test Data Source: DWH Query: SELECT * FROM SomeHugeTable Expectation: ... ... Timeout: 90 # seconds
The example above was failing after 30 seconds before the fix. Thanks
@Tereza Černá for reporting the bug.
Happy testing, wish you all green ;-)