diff --git a/t/Koha/Plugins/HtmlScrubber.t b/t/Koha/Plugins/HtmlScrubber.t
index 33b4b6f1b5..046522ff8d 100755
--- a/t/Koha/Plugins/HtmlScrubber.t
+++ b/t/Koha/Plugins/HtmlScrubber.t
@@ -17,7 +17,8 @@
use Modern::Perl;
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use Template;
subtest 'test scrubbing using default scrubber' => sub {
diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t
index 559cd2ec74..069614504a 100755
--- a/t/db_dependent/AuthorisedValues.t
+++ b/t/db_dependent/AuthorisedValues.t
@@ -1,7 +1,8 @@
#!/usr/bin/perl
use Modern::Perl;
-use Test::More tests => 17;
+use Test::More tests => 18;
+use Test::NoWarnings;
use Test::Exception;
use Try::Tiny;
diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t
index e65e01fcef..b104f128e1 100755
--- a/t/db_dependent/Koha/Acquisition/Booksellers.t
+++ b/t/db_dependent/Koha/Acquisition/Booksellers.t
@@ -18,7 +18,8 @@
use Modern::Perl;
use utf8;
-use Test::More tests => 8;
+use Test::More tests => 9;
+use Test::NoWarnings;
use t::lib::TestBuilder;
diff --git a/t/db_dependent/Koha/Auth/TwoFactorAuth.t b/t/db_dependent/Koha/Auth/TwoFactorAuth.t
index 10e7e9af2c..e0bee6c465 100755
--- a/t/db_dependent/Koha/Auth/TwoFactorAuth.t
+++ b/t/db_dependent/Koha/Auth/TwoFactorAuth.t
@@ -1,7 +1,8 @@
#!/usr/bin/perl
use Modern::Perl;
-use Test::More tests => 3;
+use Test::More tests => 4;
+use Test::NoWarnings;
use Test::Exception;
use Test::MockModule;
diff --git a/t/db_dependent/Koha/Authority.t b/t/db_dependent/Koha/Authority.t
index da9ec4fcb9..714f1fc3db 100755
--- a/t/db_dependent/Koha/Authority.t
+++ b/t/db_dependent/Koha/Authority.t
@@ -19,7 +19,8 @@
use Modern::Perl;
-use Test::More tests => 1;
+use Test::More tests => 2;
+use Test::NoWarnings;
use C4::AuthoritiesMarc;
use Koha::Authorities;
diff --git a/t/db_dependent/Koha/BackgroundJob.t b/t/db_dependent/Koha/BackgroundJob.t
index 035823d6f7..9b52d01293 100755
--- a/t/db_dependent/Koha/BackgroundJob.t
+++ b/t/db_dependent/Koha/BackgroundJob.t
@@ -19,7 +19,8 @@ use Modern::Perl;
use utf8;
use Encode;
-use Test::More tests => 6;
+use Test::More tests => 7;
+use Test::NoWarnings;
use Test::MockModule;
use Test::Exception;
use Test::Warn;
diff --git a/t/db_dependent/Koha/Encryption.t b/t/db_dependent/Koha/Encryption.t
index eee199404e..413a498e9f 100755
--- a/t/db_dependent/Koha/Encryption.t
+++ b/t/db_dependent/Koha/Encryption.t
@@ -1,6 +1,7 @@
use Modern::Perl;
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use Test::Exception;
use t::lib::Mocks;
use Koha::Encryption;
diff --git a/t/db_dependent/Koha/ILL/Request/Workflow/ConfirmAuto.t b/t/db_dependent/Koha/ILL/Request/Workflow/ConfirmAuto.t
index bb9315df0f..8e3ca87387 100755
--- a/t/db_dependent/Koha/ILL/Request/Workflow/ConfirmAuto.t
+++ b/t/db_dependent/Koha/ILL/Request/Workflow/ConfirmAuto.t
@@ -17,7 +17,8 @@
use Modern::Perl;
-use Test::More tests => 5;
+use Test::More tests => 6;
+use Test::NoWarnings;
use Test::MockModule;
use Test::MockObject;
diff --git a/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t b/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t
index 604f270f0f..1af24382a3 100755
--- a/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t
+++ b/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t
@@ -17,7 +17,8 @@
use Modern::Perl;
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use Test::MockModule;
use Test::MockObject;
diff --git a/t/db_dependent/Koha/Plugins/ILL/Backends.t b/t/db_dependent/Koha/Plugins/ILL/Backends.t
index 992677ce6e..e526d3aa0d 100755
--- a/t/db_dependent/Koha/Plugins/ILL/Backends.t
+++ b/t/db_dependent/Koha/Plugins/ILL/Backends.t
@@ -16,7 +16,8 @@
use Modern::Perl;
use File::Basename;
-use Test::More tests => 4;
+use Test::More tests => 5;
+use Test::NoWarnings;
use t::lib::Mocks;
use t::lib::TestBuilder;
diff --git a/t/db_dependent/Koha/Plugins/Overdues.t b/t/db_dependent/Koha/Plugins/Overdues.t
index d044817c17..3e020bd20d 100755
--- a/t/db_dependent/Koha/Plugins/Overdues.t
+++ b/t/db_dependent/Koha/Plugins/Overdues.t
@@ -16,7 +16,8 @@
use Modern::Perl;
-use Test::More tests => 8;
+use Test::More tests => 9;
+use Test::NoWarnings;
use Test::Warn;
use C4::Overdues qw(CalcFine);
diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t
index ca3461c119..dbefe2652b 100755
--- a/t/db_dependent/Koha/Pseudonymization.t
+++ b/t/db_dependent/Koha/Pseudonymization.t
@@ -19,7 +19,8 @@
use Modern::Perl;
-use Test::More tests => 3;
+use Test::More tests => 4;
+use Test::NoWarnings;
use Test::Warn;
use Try::Tiny;
diff --git a/t/db_dependent/Koha/REST/Plugin/Auth/PublicRoutes.t b/t/db_dependent/Koha/REST/Plugin/Auth/PublicRoutes.t
index 991a8c1597..4e5b571073 100755
--- a/t/db_dependent/Koha/REST/Plugin/Auth/PublicRoutes.t
+++ b/t/db_dependent/Koha/REST/Plugin/Auth/PublicRoutes.t
@@ -71,7 +71,8 @@ post '/public_guarantor' => sub {
}
};
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use Test::Mojo;
use t::lib::Mocks;
diff --git a/t/db_dependent/Patron/Borrower_Discharge.t b/t/db_dependent/Patron/Borrower_Discharge.t
index 869ccc18c1..0f42c5cad5 100755
--- a/t/db_dependent/Patron/Borrower_Discharge.t
+++ b/t/db_dependent/Patron/Borrower_Discharge.t
@@ -16,7 +16,8 @@
use Modern::Perl;
-use Test::More tests => 32;
+use Test::More tests => 33;
+use Test::NoWarnings;
use Test::MockModule;
use Test::Warn;
diff --git a/t/db_dependent/misc/translator/xgettext.pl.t b/t/db_dependent/misc/translator/xgettext.pl.t
index b6d2a4d1d3..622c71dc53 100755
--- a/t/db_dependent/misc/translator/xgettext.pl.t
+++ b/t/db_dependent/misc/translator/xgettext.pl.t
@@ -6,7 +6,8 @@ use File::Slurp;
use File::Temp qw(tempdir);
use FindBin qw($Bin);
use Locale::PO;
-use Test::More tests => 20;
+use Test::More tests => 21;
+use Test::NoWarnings;
my $tempdir = tempdir( CLEANUP => 1 );
diff --git a/t/db_dependent/mojo/rest-auth.t b/t/db_dependent/mojo/rest-auth.t
index 75384b95f7..4b9d5b60f5 100755
--- a/t/db_dependent/mojo/rest-auth.t
+++ b/t/db_dependent/mojo/rest-auth.t
@@ -2,7 +2,8 @@
use Modern::Perl;
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use Test::Mojo;
use Koha::Database;
diff --git a/t/db_dependent/selenium/00-onboarding.t b/t/db_dependent/selenium/00-onboarding.t
index 8cad7a86dc..61ee44c471 100755
--- a/t/db_dependent/selenium/00-onboarding.t
+++ b/t/db_dependent/selenium/00-onboarding.t
@@ -22,7 +22,8 @@
use Modern::Perl;
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use t::lib::Selenium;
use C4::Context;
diff --git a/t/db_dependent/selenium/01-installation.t b/t/db_dependent/selenium/01-installation.t
index 7f0bc02690..ba442117ca 100755
--- a/t/db_dependent/selenium/01-installation.t
+++ b/t/db_dependent/selenium/01-installation.t
@@ -22,7 +22,8 @@
use Modern::Perl;
-use Test::More tests => 2;
+use Test::More tests => 3;
+use Test::NoWarnings;
use t::lib::Selenium;
use C4::Context;
diff --git a/t/db_dependent/selenium/opac_ill_requests.t b/t/db_dependent/selenium/opac_ill_requests.t
index 20f1d49b3d..88c0e98d62 100755
--- a/t/db_dependent/selenium/opac_ill_requests.t
+++ b/t/db_dependent/selenium/opac_ill_requests.t
@@ -16,7 +16,8 @@
# along with Koha; if not, see .
use Modern::Perl;
-use Test::More tests => 1;
+use Test::More tests => 2;
+use Test::NoWarnings;
use C4::Biblio qw(DelBiblio);
diff --git a/xt/use-test-no-warnings.t b/xt/use-test-no-warnings.t
new file mode 100755
index 0000000000..4bd5ed69eb
--- /dev/null
+++ b/xt/use-test-no-warnings.t
@@ -0,0 +1,53 @@
+#/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see .
+
+use Modern::Perl;
+use Test::More tests => 2;
+use Test::NoWarnings;
+
+use Array::Utils qw( array_minus );
+
+my @t_files = qx{git grep --files-without-match "Test::NoWarnings" 't/*.t'};
+chomp for @t_files;
+
+my @exceptions = (
+
+ # Cannot be removed
+ "t/00-testcritic.t",
+
+ # bug 40386
+ "t/Edifact.t",
+
+ # bug 40387
+ "t/db_dependent/Koha/EDI.t",
+
+ # bug 40382
+ "t/db_dependent/Koha/CoverImages.t",
+
+ # bug 40442
+ "t/db_dependent/Koha/MarcOrder.t",
+
+ # bug 40375
+ "t/db_dependent/XISBN.t",
+
+ # bug 40443
+ "t/db_dependent/cronjobs/advance_notices_digest.t",
+);
+
+@t_files = array_minus( @t_files, @exceptions );
+is( scalar(@t_files), 0, "All Perl test files should contain Test::NoWarnings" )
+ or diag( sprintf "The following test files should use Test::NoWarnings:\n\t%s", join "\n\t", @t_files );