Bug 15052: Add diagnostic for the TestBuilder tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 23 Oct 2015 08:32:18 +0000 (09:32 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 23 Oct 2015 12:35:13 +0000 (09:35 -0300)
Sometimes t/db_dependent/TestBuilder.t fails with 'TestBuilder can
create a entry for every sources' but we don't know which ones have
failed.

Test plan:
Create the following file: Koha/Schema/Result/Test.pm
 package Koha::Schema::Result::Test;
 use base 'DBIx::Class::Core';
 __PACKAGE__->table("test");
 1;

If you don't have a table named 'test' in your DB,
  prove t/db_dependent/TestBuilder.t
should return a failure, but without any explanation.
With this patch you should get a diag and know what's wrong.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/TestBuilder.t

index bec4834..70aa7cd 100644 (file)
@@ -30,12 +30,15 @@ my $builder = t::lib::TestBuilder->new();
 is( $builder->build(), undef, 'build without arguments returns undef' );
 
 my @sources    = $builder->schema->sources;
-my $nb_failure = 0;
+my @source_in_failure;
 for my $source (@sources) {
     eval { $builder->build( { source => $source } ); };
-    $nb_failure++ if ($@);
+    push @source_in_failure, $source if $@;
+}
+is( @source_in_failure, 0, 'TestBuilder should be able to create an object for every sources' );
+if ( @source_in_failure ) {
+    diag ("The following sources have not been generated correctly: " . join ', ', @source_in_failure)
 }
-is( $nb_failure, 0, 'TestBuilder can create a entry for every sources' );
 
 my $my_overduerules_transport_type = {
     message_transport_type => {