Skip to content
🔬 Insight into code refactoring
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
eg
lib/Test
logotype
t
.gitignore
.travis.yml
LICENSE
META6.json
README.md

README.md

🔬 Test::Lab

Build Status Issues License Slack

Careful refactoring of critical paths. A port of Github's Scientist to Perl 6.

How do I start a lab?

Use the lab sub to build a default experiment for you:

use Test::Lab;

class MyWidget {
  method is-allowed($user) {
    lab 'widget-permissions', -> $e {
      $e.use: { $!model.check-user($user).is-valid } # old way
      $e.try: { $user.can('read', $!model) } # new way
    }
  }
}

Use the Test::Lab::Experiment class to instantiate a default experiment:

use Test::Lab::Experiment;

class MyWidget {
  method allows($user) {
    my $experiment = Test::Lab::Experiment.new(:name<widget-permissions>);
    $experiment.use: { $!model.check-user($user).is-valid } # old way
    $experiment.try: { $user.can :$!model :read } # new way

    $experiment.run;
  }
}

Change the default Experiment class to publish your results:

class MyExperiment is Test::Lab::Experiment {
  method is-enabled { ... }
  method publish($result) { ... }
}
Test::Lab::<$experiment-class> = MyExperiment;

Now you can use lab as before and it will utilize your own experiment class. This is highly useful as Test::Lab::Default provides no publishing and thus no way to gain access to the results.

You can’t perform that action at this time.