Running the Postman Integration Tests
The Ed-Fi ODS / API includes several collections of Postman tests that can be executed against a Test Harness included in the ODS / API source code.
The following instructions assume that the Ed-Fi ODS / API has been successfully set up and is running in a local environment per the instructions in the Getting Started documentation. This documentation takes you through running two options for running postman test collections:
Running Postman Test Collections via PowerShell
-
Install NVM, for windows systems you could use nvm for Windows
-
As outlined in the Getting Started Guide from a PowerShell prompt run
Initialize-PowershellForDevelopment.ps1
script followed byinitdev -usePlugins
and finallyInvoke-PostmanIntegrationTests
PS D:\ed-fi\Ed-Fi-ODS-Implementation> .\Initialize-PowershellForDevelopment.ps1
Using repositories: Ed-Fi-ODS, Ed-Fi-ODS-Implementation
Importing Module: D:\ed-fi\Ed-Fi-ODS-Implementation\Application\SolutionScripts\InitializeDevelopmentEnvironment.psm1
PS D:\ed-fi\Ed-Fi-ODS-Implementation> initdev -usePlugins
----------------------------------------
Invoke-NewDevelopmentAppSettings
----------------------------------------
<trimmed output...>
PS D:\ed-fi\Ed-Fi-ODS-Implementation> Invoke-PostmanIntegrationTests
--------------------------------------
Invoke-PostmanIntegrationTests
--------------------------------------
Using repositories: Ed-Fi-ODS, Ed-Fi-ODS-Implementation
Importing Module: D:\ed-fi\Ed-Fi-ODS-Implementation\Application\SolutionScripts\InitializeDevelopmentEnvironment.psm1
<trimmed output...> -
Test results are presented as the tests run
<trimmed output...>
------------------------------------------------------------------
| | executed | failed |
--------------------------+-------------------+-------------------
| iterations | 1 | 0 |
--------------------------+-------------------+-------------------
| requests | 89 | 0 |
--------------------------+-------------------+-------------------
| test-scripts | 281 | 0 |
--------------------------+-------------------+-------------------
| prerequest-scripts | 282 | 0 |
--------------------------+-------------------+-------------------
| assertions | 109 | 0 |
------------------------------------------------------------------
| total run duration: 13.7s |
------------------------------------------------------------------
| total data received: 254.88kB (approx) |
------------------------------------------------------------------
| average response time: 41ms [min: 3ms, max: 410ms, s.d.: 52ms] |
------------------------------------------------------------------
Invoke-Newman done in 9m22s.
------------------------
Stop-TestHarness
------------------------
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
391 1,591.07 1,620.68 9.25 36520 1 EdFi.Ods.Api.IntegrationTestHarness
Stop-TestHarness done in 45ms.
Invoke-PostmanIntegrationTests done in 9m39s.
Duration Task
-------- ----
09:39.58 Invoke-PostmanIntegrationTests
To capture the execution output of the Postman tests into a log file for full review (since the console window buffer may not be large enough to review the entire results of the test), you can do the following:
- Create a script (e.g. run-postman-tests-core.ps1) in the Ed-Fi-ODS-Implementation folder with the following content:
.\Initialize-PowershellForDevelopment.ps1
Invoke-PostmanIntegrationTests
- Create a second script (e.g. run-postman-tests.ps1) in the Ed-Fi-ODS-Implementation folder with the following content:
Start-Process powershell.exe .\run-postman-tests-core.ps1 -RedirectStandardOutput .\tests.log
This will capture the stdout from the process and write it to the specified log file instead. The shell window that is opened won't show any activity during the test run, so you'll just need to wait until it finishes.
Running Postman Test Collections via Postman
- Install and launch Postman.
- Import the Postman collections to test from the "Postman Test Suite" folder
in the Ed-Fi-ODS repository.
- In the Postman UI, click "Import".
- Click the "files" link to launch the "Open File" dialog.
- Create a Postman environment for running the collections.
- Click on "Environments" section (in the left column).
- Click the "+" symbol to create a new environment.
- Provide a name for the environment (e.g. "Ed-Fi ODS API (Integration Testing)").
- Add 4 Postman environment variables:
- ApiBaseUrl = http://localhost:8765
- ParentOrContactProperName = Parent (Ed-Fi Standard v4.x or earlier) or Contact (Ed-Fi Standard v5.x+)
- CompositesFeatureIsEnabled = true
- ProfilesFeatureIsEnabled = true
- Load and run the EdFi.Ods.Api.IntegrationTestHarness project from Tests/Integration solution folder in the Ed-Fi-Ods solution.
- Run a Postman test collection.
- Select the collection to run (Step 1 below).
- Select the Postman environment just created (Step 2 below).
- Select "Run collection" from the context menu (Steps 3 and 4 below).
- Click the "Run" button to execute and monitor the progress of all the tests in the collection.
You can easily reset the test databases at any point by performing the following steps in PowerShell:
-
In a PowerShell console, go to the root folder of the Ed-Fi-ODS-Implementation repository (previously cloned from GitHub).
-
Run the following command to initialize the PowerShell environment:
.\Initialize-PowershellForDevelopment.ps1
-
Reset the test databases by executing the following command (repeat as necessary):
Reset-TestAdminDatabase; Reset-TestSecurityDatabase; Reset-TestPopulatedTemplateDatabase