Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add diagnostic output to testbed probe.redraw() #1847

Closed
freakboy3742 opened this issue Apr 7, 2023 · 0 comments · Fixed by #1908
Closed

Add diagnostic output to testbed probe.redraw() #1847

freakboy3742 opened this issue Apr 7, 2023 · 0 comments · Fixed by #1908
Labels
enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start!

Comments

@freakboy3742
Copy link
Member

What is the problem or limitation you are having?

When running the testbed with --slow, tests run slower, but it's difficult to establish what the test is meant to be doing unless you're familiar with the test.

It would be desirable for a --slow test run to include debug output so that at each await probe.redraw() wait step, the test describes what behavior the test is expecting to see.

Describe the solution you'd like

probe.redraw() should accept an optional string argument, that allows the test developer to describe what it is that the user should be waiting for - e.g.:

button.style.background_color = RED
probe.redraw("Background color should be red")`

The message should act as a form of inline documentation of the test cases. It should be a humanised summary of any assertions that follow the redraw() call.

This message can be output with a print() call in the implementation of probe.redraw() on each platform. However, the output should only occur if running in --slow mode; and should occur before the 1s sleep (so we know what we're sleeping to see).

Running in --slow mode should also turn on -s in the call to pytest, so that streaming output is visible.

If no message is provided, a default message of "Waiting for redraw") should be output.

The existing test cases in the testbed app should be updated to include meaningful probe redraw explanations.

It would also be desirable to include a "console clearing" print("\n") at the start of tests when running in slow mode. Otherwise, the first redraw wait will be on the line with the test name. The first probe.redraw() should usually be in the setup of the probe itself, so including a \n in that print message may be sufficient.

Describe alternatives you've considered

Do nothing; or include ad-hoc debug statements as part of the test authoring process.

Additional context

To see the current testbed behaviour, set up a Toga development environment, and run:

cd testbed
briefcase dev --test

To see the behavior in slow mode, run:

cd testbed
briefcase dev --test -- tests/widgets/test_button.py --slow

There is a separate probe.redraw() call in each platform's testbed probe.

Ultimately, it would be preferable for the string argument to probe.redraw() to not be optional. However, all existing tests would need to be updated before this could be enabled. A partial solution that uses an optional message and updates some of the testbed tests would be acceptable as a first pass.

@freakboy3742 freakboy3742 added enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start! labels Apr 7, 2023
@freakboy3742 freakboy3742 mentioned this issue Apr 26, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant