Debug a C# scripted rule
Debug a Service Virtualization C# scripted rule in a Visual Studio project, using the debugging features of Visual Studio, or of another C# IDE.
For example, you may want to trace the flow of your script and inspect values inside the variables to better understand what is happening when your script runs. This can help you to more effectively troubleshoot your issues.
To debug a Service Virtualization C# scripted rule in an external tool, enable the debug feature in Service Virtualization Designer. If your virtual service is deployed on Service Virtualization Server, enable the debug feature on the Server machine as well.
Edit the file scripted-rule-context.xml located in <Service Virtualization installation folder>\bin\Config.
For example, for the Designer, the file is located by default in C:\Program Files\Micro Focus\Service Virtualization Designer\Designer\bin\Config\scripted-rule-context.xml.
- Change the value of
- Change the value
Debug the script
- From the Data Model Editor, open the C# rule in a Visual Studio project.
- Add a breakpoint (F9).
- Attach the debugger to the VirtualServiceDesigner process (Ctrl+Alt+P).
- In Service Virtualization, switch your virtual service to Simulating mode.
Open Simulation preview and click on a row in the data model.
Alternatively, perform another action that triggers the execution of your script, such as intercepting a request.
While the script runs, the debugger will hit your breakpoints when the flow of execution reaches them. When hit, you can view the content of your variables, step through the code, inspect the script internals, and resume execution when you are ready.