Skip to content

MadcapJake/Test-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔬 Test::Lab

GitHub Workflow Status Issues License

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

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.

About

🔬 Insight into code refactoring

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages