Skip to content

Commit a343037

Browse files
Merge pull request #1000 from NHSDigital/feature/hakh11-NRL-1563-enhanceDebuggingCapability
Feature/hakh11 nrl 1563 enhance debugging capability
2 parents b0bfcac + 014afad commit a343037

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ To run all the feature integration tests:
9595
make test-features-integration
9696
```
9797

98-
To run indivudal feature test scenario(s) using the custom tag :
98+
To run individual feature test scenario(s) using the custom tag :
9999

100100
1. Add `@custom_tag` before each 'Scenario' that needs to be run (in each .feature file)
101101
2. Run the command below:
@@ -104,12 +104,77 @@ To run indivudal feature test scenario(s) using the custom tag :
104104
make integration-test-with-custom_tag
105105
```
106106

107-
To run all the feature integration tests and generate an interactive Allure report therafter :
107+
To run all the feature integration tests and generate an interactive Allure report thereafter :
108108

109109
```
110110
make test-features-integration-report
111111
```
112112

113+
### Debugging Behave Integration Tests in VS Code
114+
115+
Integration tests can be debugged directly in **VS Code** using a launch configuration. Instructions on how to set this up for the first time and run the debugger are below.
116+
117+
---
118+
119+
#### 1. Create the Launch Configuration
120+
121+
To get started:
122+
123+
1. Open VS Code and press `Ctrl+Shift+P`
124+
2. Search for **“Add Configuration”** and select it
125+
3. Choose **Python** > **Module**
126+
4. Replace the generated entry in `.vscode/launch.json` with an appropriate launch.json configuration. Below is a example which can be modified as required:
127+
128+
```json
129+
// .vscode/launch.json
130+
{
131+
"version": "0.2.0",
132+
"configurations": [
133+
{
134+
"name": "Debug Behave",
135+
"type": "debugpy",
136+
"request": "launch",
137+
"module": "behave",
138+
"args": [
139+
"-D",
140+
"env=example-env",
141+
"tests/features",
142+
"-D",
143+
"integration_test=true",
144+
"--tags=@custom_tag"
145+
],
146+
"console": "integratedTerminal",
147+
"justMyCode": true,
148+
"env": {
149+
"PYTHONPATH": "${workspaceFolder}" // adds your project code to Python path
150+
},
151+
"cwd": "${workspaceFolder}" // resolves to the root directory
152+
}
153+
]
154+
}
155+
```
156+
157+
Once steps 1-4 are done, "Debug Behave" should appear in the Run and Debug panel.
158+
159+
#### 2. Customizing the Debug Configuration
160+
161+
You can tailor the args section in .vscode/launch.json to suit your specific environment, tags, or test structure.
162+
163+
For example:
164+
To run only tests with the @api tag, set the --tags accordingly:
165+
166+
```
167+
"args": ["--tags=@api"..]
168+
```
169+
170+
#### 3. Running the Debugger
171+
172+
To start debugging using the launch configuration from VS Code:
173+
174+
1. Go to the Run and Debug panel `Ctrl+Shift+D`
175+
2. Ensure **“Debug Behave”** (if this is the name used in **“launch.json”**) is selected from the dropdown at the top
176+
3. Press `F5` to start debugging
177+
113178
### Smoke testing
114179

115180
For smoke tests, you need to have deployed your infrastructure (using Terraform).

0 commit comments

Comments
 (0)