Rex::Test::Base - Basic Test Module
This module is a basic Test module to test your Code with the help of local VMs. To create a test you first have to create the "t" directory. Then you can create your test files inside this directory.
use Rex::Test::Base; use Data::Dumper; use Rex -base; test { my $t = shift; $t->name("ubuntu test"); $t->base_vm("http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova"); $t->vm_auth(user => "root", password => "box"); $t->run_task("setup"); $t->has_package("vim"); $t->has_package("ntp"); $t->has_package("unzip"); $t->has_file("/etc/ntp.conf"); $t->has_service_running("ntp"); $t->has_content("/etc/passwd", qr{root:x:0:}ms); run "ls -l"; $t->ok($? == 0, "ls -l returns success."); $t->finish; }; 1; # last line
Constructor if used in OO mode.
my $test = Rex::Test::Base->new(name => "test_name");
The name of the test. For each test a new vm will be created named after $name.
Authentication option for the VM.
The url to a vm that should be used as base VM.
The redirected SSH port. Default 2222.
The task to run on the test vm.
Test if the content of $file matches against $regexp.
Test if the package $package is installed.
Test if the file $file is present.
Test if the service $service is running.
Test if the service $service is stopped.
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rex
CPAN shell
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.