Working with a Project
How to work with CAT project in PowerShell?
Open a project
When you are in a directory that contains a single .cat.yaml
file, opening a project is as easy as this:
Open-CatProject
If your porject file is elsewhere, you can either navigate there (cd ....
) and run Open-CatProject
, or you can tell CAT where the file is:
Open-CatProject "D:\MyTestProject\Tests.cat.yaml"
Again, you can provide either full path or a path to a directory containing a single .cat.yaml
file.
Open-CatProject
, it does NOT run the tests immediatelly. It just parses the project file, loads data sources and loads test definitions. But no tests are actually started. If you want a “shortcut”, see Invoke-CatProject
.What project is open?
To check whether you have an open project and see its details, run this:
Get-CatProject
It outputs details about the open project:
PowerShell returns objects, so you can work with the output easily. Check e.g. list of all tests in the project like this:
(Get-CatProject).Tests
# or
$project = Get-CatProject
$project.Tests
So that is good for programatically work with the values, but for getting quick overview about the project, what data sources it loaded, how many tests from where etc., use Show-CatProject
instead:
Show-CatProject
You can simply see there are two data sources defined, used by 133 tests loaded from SQL server and 1 test loaded from YAML file. There are outputs defined, YAML, JSON, XLSX and TRX.
Data sources and tests
If you need information about data sources loaded for your open project, issue this command:
Get-CatDataSource
The same for tests (definitions of tests, not test results):
Get-CatTest
If you are loading tests or data source definitions from other location than your project file, you can verify if CAT interpreted everything correctly using these commands:
Get-CatDataSourceList
Get-CatTestList
Close CAT project
If you don’t intent to work with the project, you can close it:
Close-CatProject