Load Tests from ...
How to load test definitions from ...?
You can have all your definitions of Data Sources and Tests in your project file. But it is by far not the only option.
First, why would you have test definitions elsewhere, why not keep them in a simple single version-control-friendly text file?
-
You will have too many tests. With CAT you’ll quickly get addicted and you’ll want to know many many things are OK. Managing hundreds or tousands of tests in a single file is out of question.
-
You will be often testing databases. You may want to autogenerate tests in a database and instruct CAT to execute them.
-
Business people are often those with the best knowledge of data and know basics of SQL. Drag them into the process. But they will not want to handle YAML - you’ll have to give them MS Excel.
CAT does not care much from where Data Source and Test definitions come. You can get them from any implemented Provider.
Instead of defining data sources and tests directly in the project file like this:
Data Sources:
- Name: some data source
# .... abbreviated
Tests:
- Name: some test
# ... abbreviated
you can tell CAT to:
Get list of data sources from:
- Provider: SqlServer@1
Connection string: data source=localhost;integrated security=true;initial catalog=Testing
Query: SELECT * FROM [DataSource]
Get list of tests from:
- Provider: SqlServer@1
Connection string: data source=localhost;integrated security=true;initial catalog=Testing
Query: SELECT * FROM [Test]
You can combine these approaches. E.g., have your data source defintiions in your project file, but load tests from a database:
Data Sources:
- Name: some data source
# .... abbreviated
Get list of tests from:
- Provider: SqlServer@1
Connection string: data source=localhost;integrated security=true;initial catalog=Testing
Query: SELECT * FROM [Test]
You can also use different providers for each:
Get list of data sources from:
- Provider: Yaml@1
Connection string: MyConnections.yaml # file in the same directory as your project file
Query: /Data Sources # path to where the data sources are
Get list of tests from:
- Provider: Excel@1
Connection string: MyTests.xlsx # file in the same directory as your project file
Query: SELECT * FROM [Sheet1]
Do you prefer to generate tests using a stored procedure? Do you have more of them? You can define more:
Get List of Tests From:
- Provider: SqlServer@1
Connection String: "%DWH_CONNECTION_STRING%"
Query: EXEC [Test].[GetSmokeTests]
- Provider: SqlServer@1
Connection String: "%DWH_CONNECTION_STRING%"
Query: EXEC [Test].[GetIntegrationTests]
- Provider: Excel@1
Connection String: TestsFromBusiness.xlsx
Query: SELECT * FROM [Tests];
# ... abbreviated
Long story short, CAT is flexible. It can load tests (and / or data sources) definitions from almost anywhere. Organize your tests as you like. CAT project files give you tremendous flexibility.