You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/README.md
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,10 +94,49 @@ Our integration tests are based on functions from the samples project. To run in
94
94
}
95
95
```
96
96
97
-
## Troubleshooting Tests
97
+
## Troubleshooting Test Failures
98
98
99
99
This section lists some things to try to help troubleshoot test failures
100
100
101
+
### Debug Integration tests
102
+
103
+
You can debug tests locally by following these steps.
104
+
105
+
The first part is to identify what you want to debug so you know which process to attach to. There are between 2 and 3 different processes to attach to :
106
+
107
+
#### Test Runner
108
+
109
+
To debug the test code itself (anything under the `test` folder) you will need to attach to the VS Test Runner that's running the tests.
110
+
111
+
Visual Studio : Right click on the test in the test explorer and click "Debug"
112
+
Visual Studio Code : Install a test explorer extension such as [.NET Core Test Explorer](https://marketplace.visualstudio.com/items?itemName=formulahendry.dotnet-test-explorer), go to the Tests panel, find the `.NET Test Explorer` view, right click the test you want to run and click "Debug Test"
113
+
114
+
#### Function Host
115
+
116
+
To debug either any core extension code (anything under the `src` folder) OR function code for .NET In-Process tests you will need to attach to the Function Host that's running the functions.
117
+
118
+
To do this and be able to set breakpoints before the test runs you will need to follow these steps :
119
+
120
+
1. Go to [IntegrationTestBase.cs](./Integration/IntegrationTestBase.cs) and in `StartFunctionHost` add a `return;` on the first line - this is to skip having the test start up the function host itself (since you'll be doing it manually)
121
+
2. `cd` to the directory containing the functions to run - this will be in the `test/bin/Debug/net6/SqlExtensionSamples/<LANG>` folder (e.g. `test/bin/Debug/net6/SqlExtensionSamples/samples-csharp`)
122
+
3. Run `func host start --functions <FUNCTION_NAME>` - replacing `<FUNCTION_NAME>` with the name of the function you want to debug (e.g. `func host start --functions AddProduct`)
123
+
4. Attach to the func.exe process
124
+
* Visual Studio : Use `Attach to Process...`.
125
+
* VS Code you can use `Attach to Function Host` debug target (at the root level of the project)
126
+
127
+
**NOTE** If you don't see your breakpoints appear make sure you're using the correct version of the extension DLL. For non-.NET languages this will mean copying over the latest locally built version to the extension bundle as detailed [here](#extension-bundle). If you don't do this the host will be using a different version of the DLL that you won't have symbols for so breakpoints won't be able to load.
128
+
5. Run your test
129
+
130
+
#### Function Worker (Non .NET Isolated Functions only)
131
+
132
+
For all functions that run in a worker process (which is everything other than .NET In-Process functions) if you need to debug the function code itself then you will need to use the native debugger to attach to the process. The easiest way to do that is to follow these steps:
133
+
134
+
1. Open up a new instance of VS Code into the samples/test folder containing the function you want to debug (e.g. `samples/samples-powershell` or `test/Integration/test-powershell`)
135
+
2. Modify the `.vscode/tasks.json` file for that folder and add `--functions <FUNCTION_NAME>` to the end of the command property for `func: host start`. (e.g. `"command": "host start --functions AddProduct"`)
136
+
3. Update the `local.settings.json` in that folder and fill in the value for `SqlConnectionString` (since the test is no longer controlling the startup of the function host)
137
+
4. Click F5 to run the `Attach to <LANG> Functions` target, this will launch the specified function and attach the debugger to it
138
+
5. Run your test
139
+
101
140
### Enable debug logging on the Function
102
141
103
142
Enabling debug logging can greatly increase the information available which can help track down issues or understand at least where the problem may be. To enable debug logging for the Function open [host.json](../samples/samples-csharp/host.json) and add the following property to the `logLevel` section, then rebuild and re-run your test.
0 commit comments