MT::Test
NAME
MT::Test - a framework for testing Movable Type plugins.
VERSION
0.11
DESCRIPTION
MT::Test is a framework for testing Movable Type plugins. It is a subclass of Test::Builder::Module from Test::More that adds additional MT specific tests and functionality.
Those familiar with Test::More will be right at home. The one major addition is the ability to test template tag output using one method and half a dozen testing specific template tags.
The framework includes a command tool for running the tests with
specific configuration or even with a fresh default database. See the
manpage for mtt.
METHODS
- ok
- is
- isnt
- like
- unlike
- cmp_ok
- diag
These methods are inherited from Test::More. See the Test::More manpages for more.
- use_ok
- require_ok
These methods are essentially the same found in Test::More however the MT system libraries such as
extlibare also considered. - run_test_tmpl( $tmpl, [&begin, &end]);
This method takes a template and performs the embedded tests on its output. These tests are represented using one of the special test operation tags providing by this framework. (See TAGS).
A string parameter containing the template markup for the test is required. You can optionally pass references a reference to code to run before and after the template test. These methods are useful for initializing the context of doing follow-up test on the final context after a template run.
- has_plugin($plugin_sig)
This method will test the MT system for the existence of a specific plugin and will fail if it is not found. A plugin signature string such as 'plugins/feeds/mt-feeds.pl' is required.
- has_plugin_enabled($plugin_sig)
This method will test if a specific plugin is enabled in the system. It will fail if it is disabled or not found. A plugin signature string such as 'plugins/feeds/mt-feeds.pl' is required.
TAGS
- MTTestIs var= stash= val= test_name= blank=1
This tag tests if the output of its contents matches a specific value. The value to test for can come from a template variable using the
varattribute, the stash using thestashattribute or from the tag'svalattribute. In order to test if the contents is blank (an empty string) pass a true value to theblankattribute. One and only one of these attributes must be passed.Optionally the
test_nameattribute can be used to pass a string identify the test when run. - MTTestIsNot var= stash= val= test_name= blank=1
This tag tests if the output of its contents does NOT match a specific value. It is the opposite of
MTTestIsand takes the same attributes. - MTTestCompareOK var= stash= val= test_name= blank=1 op=
This tag tests if the output of its contents does NOT match a specific value.
The
opattribute is required attribute ofand must equal one of Perl's standard string comparison operators: eq equals ne not equal lt less than gt greater than le less than equal ge greater then or equalUsing
op='eq'is the equivalent ofMTTestIsandop='ne'is the equivalent of. Optionally the
test_nameattribute can be used to pass a string identify the test when run. - MTTestLike pattern= test_name=
This tag will test if the contained output matches the regular expression passed in using the required
patternattribute.test_nameis optional, but recommend for better feedback. - MTTestUnlike pattern= test_name=
This tag will test if the contained output does not match the regular expression passed in using the required
patternattribute.test_nameis optional, but recommend for better feedback.
REQUIREMENTS
MT::Test requires at least Movable Type 3.3 or Movable Type Enterprise
1.02. MT::Test also requires MT::Tool and
Test::Simple.
KNOWN ISSUE
I'm not entire statisfied with one common occurance when using
run_test_tmpl.
The test count is not incremented properly if a test template has errors
or in some cases when a condition causes a test not to run at all. Need to
devise a means of skipping X tests if a template has an error or skips any
tests. Perhaps run_test_tmpl should be considered a test in
and of itself whose result is posted after all other processing?
AUTHOR & COPYRIGHT
MT::Test is Copyright 2006, Appnel Internet Solutions, LLC. http://appnel.com/. All rights reserved.
