Skip to content

STH GUI

Adrien Quillet edited this page Feb 16, 2023 · 5 revisions

Even if, as developpers, we only swear by command line tools and scripts, when it comes to write and run unit tests, it is nice to have access to a nice and fully integrated GUI.

STH provides a fully-integrated way to create, run and debug unit tests, shortcuts to efficientlly activate STH features, and test results feeback directly in Godot Editor.

Simple Test Harness dock view

The STH dock view is the main viex of this addon. From this view, you can run and consult tests results.

This view can be divided into three elements:

  • a toolbar, where you can activate STH functionnalities,
  • a tree view, that will display tests results,
  • a read-only text view, that displays selected tested method execution logs

Tip ! This view can be move to another dock position by dragging it, or using the dock menu.

Toolbar

The toolbar contains the following actions :

  • Clear : clear the report view from its content,
  • Run all tests : re-run tests that are in the current report, irrespective of test case results. They are all run,
  • Run failed test cases : re-run test cases that are in the current report, only if they are not successful,
  • Stop tests : stop the running test suite. It is stopped as soon as possible,
  • Expand all : expand all test case reports to see all elements (test cases, tested methods and assertions),
  • Collaspe all : collapse all test case reports.

Those actions might not be always available : depending on the context, buttons can be disabled.

Report view

The report view will display test results as soon as they are available. Once your test suite is finished, you can consult, for each test case, and for each test case method, each assertion result.

The report view is a 3-depth tree view:

  • first depth represents test cases, i.e. test scripts,
  • second depth represents test case methods,
  • last depth represents assertions run by test method.

The execution time of each test case and test case method is also available on the right.

From here, you can see if a test case is successful or not, and, if not, why it's a failure. If text is too long, you can augment dock width, or put your mouse over an element to show a tooltip containing the full text.

The report view is not just a read-only view ! You can interact with it:

  • by double clicking on a test case, the editor Script main view will open on the associated test case script,
  • by double clicking on a test method, the editor Script main view will open on the associated test case script, on the associated method.

Log view

The log view shows up when selecting a tested method. It will display method execution logs. If no log were produced, the view will remain empty.

This view cannot be edited, but you can copy texte from it 😉.

Script editor integration

STH provides some nice features directly in Godot Script Editor. Those features are available as soon as the edited script is a TestCase

Run a method from editor

In front of every test method, a gutter icon will show up. By clicking on the icon, the test method will be immediatly run and its result displayed in the STH dock view.

Activating this feature automatically saves the edited script, so you should not be worried about what was run 👍.

Dedicated popup menu entries

When opening script editor popup menu, new entries will show up, depending on the context, to easily run or debug your tests:

  • Run test case will run all tests from your test case,
  • Debugtest case will run all tests from your test case, in debug mode. In this mode, you can use breakpoints to easily debug your tests.

If popup menu is openened when editor caret is on a test method, two more entries will appear :

  • Run test function will run the active (currently editing) test function, and only this one,
  • Debug test function will run the active (currently editing) test function, and only this one, in debug mode. In this mode, you can use breakpoints to easily debug your tests.

Tip ! Each run entry has an assigned shortcut. This shortcut can be used without opening the popup menu, if the script editor has focus. That can save a lot of time and clicks !

Filesystem dock integration

Filesystem dock popup menu now has STH features to easily run tests:

  • From any folder, you can run or debug all tests recursivly. Note that if folder does not contains test cases, the entry is still available,
  • You can also run a single test case from the filesystem dock view by selecting it and activating the associated functionnality in popup menu.

Tip ! Each run entry has an assigned shortcut. This shortcut can be used without opening the popup menu, if the filesystem dock view is focused. That can save a lot of time and clicks !

Project tools integration

From Projecttools, you can run or debug all available test cases in your Godot project, from everywhere !

Tip ! Run entry has an assigned shortcut. This shortcut can be used without opening the popup menu, from anywhere in Godot editor. That can save a lot of time and clicks !

Clone this wiki locally