We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Radically simple testing in Raku

Formale Metadaten

Titel
Radically simple testing in Raku
Serientitel
Anzahl der Teile
287
Autor
Lizenz
CC-Namensnennung 2.0 Belgien:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen.
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
Some languages offer a very simple syntax for testing via assertion statements, for example with an assert function that creates a simple test that passes if given a true value and fails for anything else. This style of testing is admirably concise, but can lead to cryptic test messages that make it very difficult to determine what a test was attempting to check without opening up the file containing the failing test. At the other extreme, it's possible to write very expressive tests with a fluent, method-chaining API. For example, using the Chai.js assertion library, a test might read beverages.should.have.property('tea').with.lengthOf(3). This allows tests to automatically generate much more useful messages but comes at the cost of creating a fairly complex test API with many new methods to learn. Raku's core Test module falls somewhere between these two extremes – it offers an API with a handful of functions that's easier to learn than a full fluent API but more expressive than simple assert statements. This is a sensible compromise. But I claim (assert?) that, with a bit of metaprogramming trickery, Raku lets us have the best of both worlds: we can have a zero-learning-curve test API that's just as simple as assert statements while also being just as expressive as a long chain of method calls in a fluent style. I'll present this style of testing, discuss its use in Raku, and consider ways in which Raku lets us improve on the status quo.