Software testing
These are my posts about software testing, ensuring it works correctly and as expected.
Testing the width of a page on a mobile device using Playwright
Create a new browser context with a narrow screen, then get
document.body.scrollWidthto get the width of the displayed page.Using Playwright to test my static sites
Playwright is a testing library that lets you control a browser and check how the page is behaving, and it’s great for testing and scripting web apps.
Start a Caddy server in a subprocess during a Python session
Start the server with
subprocess.Popen, poll until it’s available, yield the base URL, then clean up the process when you’re done.Use the
-vflag to get verbose output from Go testsThis prints all
t.Logandt.Logfcalls, even if the test succeeds or times out.Repeatedly run flaky Go tests with
stressIt runs your test hundreds of times, which can be useful for finding flaky failures.
How to list the tests that will be run by a
go testcommandUse
go test -list={pattern}.Collecting pytest markers from failing tests
You can annotate tests with markers, and using the
pytest_collection_modifyitemsandpytest_terminal_summaryhooks you can get a list of markers for tests that failed.How I test Rust command-line apps with
assert_cmdSome practical examples of how this handy crate lets me write clear, readable tests.
Run a randomly selected subset of tests with pytest
By reading the code for the
pytest-random-orderplugin, I was able to write a new plugin that runs a random subset of tests.Testing JavaScript without a (third-party) framework
The browser can be a pretty good place to run your JavaScript tests.
The Hypothesis continuous release process
How we do continuous releases of hypothesis-python, and why.
Why does Hypothesis try the same example three times before failing?
Why I use py.test
Why py.test is my unit test framework of choice in Python.
Introduction to property-based testing
Testing with randomly generated examples can be a good way to uncover bugs in your code.
