Problems running tests in a RT extension


I’m writing a extension for RT 4.4 and I am struggling with getting the unit tests to run properly.

My test file xt/basic.t contains the following:

  use strict;
  use warnings;

  use RT::Extension::CSVCustomFields::Test tests => undef;


  # Load the General Queue
  my $queue = RT::Test->load_or_create_queue( Name => 'General' );
  ok( $queue->id, "loaded the General queue" );

  # Create a new customfield
  my $cf = RT::CustomField->new(RT->SystemUser);
  ok( $cf->Create( Name => 'testcsv', Queue => $queue->id, Type => 'Freeform' ) );

  my ($baseurl, $agent) = RT::Test->started_ok;


I’m running the tests as follows and get the following output:

$ perl -Ilib xt/basic.t

ok 1 - There is no etc dir: no schema
ok 2 - There is no etc dir: no ACLs
ok 3 - There is no etc dir: no data
ok 4 - use RT::Extension::CSVCustomFields;
ok 5 - use RT::CustomField;
ok 6 - loaded the General queue
ok 7
# did not get expected USR1 for test server readiness
ok 8 - started plack server ok
Can't locate object method "new" via package "RT::Test::Web" at /home/wheldonm/rt4-test-modules/lib/RT/Test/ line 68.
Can't locate object method "new" via package "RT::Test::Web" at /home/wheldonm/rt4-test-modules/lib/RT/Test/ line 68.
not ok 9 - no warnings
#   Failed test 'no warnings'
#   at /home/wheldonm/rt4-test-modules/lib/RT/ line 1783.
# There were 1 warning(s)
#       Previous test 8 'started plack server ok'
#       Can't locate object method "new" via package "RT::Test::Web" at /home/wheldonm/rt4-test-modules/lib/RT/Test/ line 68.
#  at /home/wheldonm/.perlbrew/libs/current@martin/lib/perl5/Log/Dispatch/ line 84.

I’ve also tried invoking using the following, but with similar results:

$ prove -l lib -v xt

It feels like I’m not invoking the tests correctly, but I’ve not found any documentation telling me how to.
Sorry about the long post. Any help would be much appreciated.



Seems that I was invoking the tests incorrectly, I should read the
instructions more closely.
I hadn’t set the RTHOME variable :frowning:

So for anyone with the same issue in the future:

cd rt-extension-csvcustomfields
export RTHOME=/opt/mytestrtinstance; prove -l lib -v xt

Sorry for the noise


1 Like

One other thing to add right before the done_testing call is:

undef $agent;

That will clean up the test web object and avoid additional warnings that will show up as test failures.

1 Like