From 3c844e0cb33c10e0a5b24b1f448a865798c35987 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 3 Jul 2008 13:34:03 -0500 Subject: [PATCH] test suite: way to run single test file Added support for a new target in the test Makefile to run a single test module. If you do (for example) make test-single TEST_FILES=lib/KohaTest/Biblio.pm only the tests in that module will be run. Unlike the full test suite as run via 'make test', 'make test-single' does not clear the test database before running the tests. Please note that "TEST_FILES=path/to/test/class.pm" is required when using 'make test-single'. Signed-off-by: Andrew Moore Signed-off-by: Joshua Ferraro --- t/Makefile | 4 ++++ t/lib/KohaTest.pm | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/t/Makefile b/t/Makefile index 213a513e4d..b135359db2 100644 --- a/t/Makefile +++ b/t/Makefile @@ -62,6 +62,10 @@ test :: config_file $(ZEBRA_CONF_FILES) $(SCRIPTS) KOHA_CONF=$(TEST_CONF_FILE) PERL5LIB=$(PERL5LIB) TEST_CLASS=$(TEST_CLASS) RUN_EXPENSIVE_TESTS=$(RUN_EXPENSIVE_TESTS) \ $(PROVE) $(PROVE_FLAGS) $(TEST_FILES) +test-single :: config_file $(ZEBRA_CONF_FILES) $(SCRIPTS) + KOHA_CONF=$(TEST_CONF_FILE) PERL5LIB=$(PERL5LIB) RUN_EXPENSIVE_TESTS=1 SINGLE_TEST=1 \ + $(PROVE) $(PROVE_FLAGS) -Ilib $(TEST_FILES) + fulltest :: RUN_EXPENSIVE_TESTS = 1 fulltest :: test diff --git a/t/lib/KohaTest.pm b/t/lib/KohaTest.pm index 8ff9fd0822..31183eee44 100644 --- a/t/lib/KohaTest.pm +++ b/t/lib/KohaTest.pm @@ -19,12 +19,28 @@ use C4::Search; use C4::Installer; use C4::Languages; use File::Temp qw/ tempdir /; +use CGI; # Since this is an abstract base class, this prevents these tests from # being run directly unless we're testing a subclass. It just makes # things faster. __PACKAGE__->SKIP_CLASS( 1 ); +INIT { + if ($ENV{SINGLE_TEST}) { + # if we're running the tests in one + # or more test files specified via + # + # make single-test TEST_FILES=lib/KohaTest/Foo.pm + # + # use this INIT trick taken from the POD for + # Test::Class::Load. + start_zebrasrv(); + Test::Class->runtests; + stop_zebrasrv(); + } +} + use Attribute::Handlers; =head2 Expensive test method attribute -- 2.39.5