author-classSafety.t 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. use strict;
  2. use warnings;
  3. use TestRail::API;
  4. use Test::More;
  5. use Test::Fatal;
  6. use Class::Inspector;
  7. #plan('skip_all' => "these tests are for testing by the author") unless $ENV{'AUTHOR_TESTING'};
  8. my $tr = TestRail::API->new('http://hokum.bogus','bogus','bogus',undef,1);
  9. #Call instance methods as class and vice versa
  10. like( exception {$tr->new();}, qr/.*must be called statically.*/, "Calling constructor on instance dies");
  11. my @methods = Class::Inspector->methods('TestRail::API');
  12. my @excludeModules = qw{Scalar::Util Carp Clone Try::Tiny HTTP::Request LWP::UserAgent Data::Validate::URI};
  13. my @tmp = ();
  14. my @excludedMethods = ();
  15. foreach my $module (@excludeModules) {
  16. @tmp = Class::Inspector->methods($module);
  17. push(@excludedMethods,@{$tmp[0]});
  18. }
  19. foreach my $method (@{$methods[0]}) {
  20. next if grep {$method eq $_} qw{new buildStepResults _checkInteger _checkString};
  21. next if grep {$_ eq $method} @excludedMethods;
  22. like( exception {TestRail::API->$method}, qr/.*called by an instance.*/ , "Calling $method requires an instance");
  23. }
  24. done_testing();