-
Notifications
You must be signed in to change notification settings - Fork 33
Debugging
This page describes useful debugging techniques when working on the core software.
If you are working with the API on external packages, you should use package debugging techniques.
The integration tests exercise many aspects of Nion Swift. It is often easier to debug a specific test than trying to debug while the user interface is running. When running integration tests, the normal UI is replaced by TestUI, which is a simulated user interface.
If you're running Nion Swift the UI and you want to see how the user interface reaches a bit of code, insert the following thunk of Python into the source code, run the application, and exercise the user interface to reach the code. This code will print a stack trace of how execution reached that point in the code.
import traceback
traceback.print_stack()
You can also use this technique when running unit tests.
Once you know how the errant code is reached, you can write an integration test to reach the same point and debug using that test rather than the full user interface.
If an existing or new test fails, you can run the particular test under debugger from tools like PyCharm. In most cases, it is easy to step through the code and reach the error state.
It is not as easy to run the actual user interface under the debugger - so it is usually easiest to isolate the bug using a test and run the debugger with the TestUI.