.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test2::Manual::Testing 3perl" .TH Test2::Manual::Testing 3perl 2024-09-01 "perl v5.40.0" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Test2::Manual::Testing \- Hub for documentation about writing tests with Test2. .SH DESCRIPTION .IX Header "DESCRIPTION" This document outlines all the tutorials and POD that cover writing tests. This section does not cover any Test2 internals, nor does it cover how to write new tools, for that see Test2::Manual::Tooling. .SH "NAMESPACE MAP" .IX Header "NAMESPACE MAP" When writing tests there are a couple namespaces to focus on: .IP Test2::Tools::* 4 .IX Item "Test2::Tools::*" This is where toolsets can be found. A toolset exports functions that help you make assertions about your code. Toolsets will only export functions, they should not ever have extra/global effects. .IP Test2::Plugins::* 4 .IX Item "Test2::Plugins::*" This is where plugins live. Plugins should not export anything, but instead will introduce or alter behaviors for Test2 in general. These behaviors may be lexically scoped, or they may be global. .IP Test2::Bundle::* 4 .IX Item "Test2::Bundle::*" Bundles combine toolsets and plugins together to reduce your boilerplate. First time test writers are encouraged to start with the Test2::V0 bundle (which is an exception to the namespace rule as it does not live under \&\f(CW\*(C`Test2::Bundle::\*(C'\fR). If you find yourself loading several plugins and toolsets over and over again you could benefit from writing your own bundle. .IP Test2::Require::* 4 .IX Item "Test2::Require::*" This namespace contains modules that will cause a test to skip if specific conditions are not met. Use this if you have tests that only run on specific perl versions, or require external libraries that may not always be available. .SH "LISTING DEPENDENCIES" .IX Header "LISTING DEPENDENCIES" When you use Test2, specifically things included in Test2::Suite you need to list them in your modules test dependencies. It is important to note that you should list the tools/plugins/bundles you need, you should not simply list Test2::Suite as your dependency. Test2::Suite is a living distribution intended to represent the "current" best practices. As tools, plugins, and bundles evolve, old ones will become discouraged and potentially be moved from Test2::Suite into their own distributions. .PP One goal of Test2::Suite is to avoid breaking backwards compatibility. Another goal is to always improve by replacing bad designs with better ones. When necessary Test2::Suite will break old modules out into separate dists and define new ones, typically with a new bundle. In short, if we feel the need to break something we will do so by creating a new bundle, and discouraging the old one, but we will not break the old one. .PP So for example, if you use Test2::V0, and Dist::Zilla you should have this in your config: .PP .Vb 2 \& [Prereqs / TestRequires] \& Test2::V0 = 0.000060 .Ve .PP You \fBSHOULD NOT\fR do this: .PP .Vb 2 \& [Prereqs / TestRequires] \& Test2::Suite = 0.000060 .Ve .PP Because Test2::V0 might not always be part of Test2::Suite. .PP When writing new tests you should often check Test2::Suite to see what the current recommended bundle is. .PP \fIDist::Zilla\fR .IX Subsection "Dist::Zilla" .PP .Vb 2 \& [Prereqs / TestRequires] \& Test2::V0 = 0.000060 .Ve .PP \fIExtUtils::MakeMaker\fR .IX Subsection "ExtUtils::MakeMaker" .PP .Vb 7 \& my %WriteMakefileArgs = ( \& ..., \& "TEST_REQUIRES" => { \& "Test2::V0" => "0.000060" \& }, \& ... \& ); .Ve .PP \fIModule::Install\fR .IX Subsection "Module::Install" .PP .Vb 1 \& test_requires \*(AqTest2::V0\*(Aq => \*(Aq0.000060\*(Aq; .Ve .PP \fIModule::Build\fR .IX Subsection "Module::Build" .PP .Vb 7 \& my $build = Module::Build\->new( \& ..., \& test_requires => { \& "Test2::V0" => "0.000060", \& }, \& ... \& ); .Ve .SH TUTORIALS .IX Header "TUTORIALS" .SS "SIMPLE/INTRODUCTION TUTORIAL" .IX Subsection "SIMPLE/INTRODUCTION TUTORIAL" Test2::Manual::Testing::Introduction is an introduction to writing tests using the Test2 tools. .SS "MIGRATING FROM TEST::BUILDER and TEST::MORE" .IX Subsection "MIGRATING FROM TEST::BUILDER and TEST::MORE" Test2::Manual::Testing::Migrating Is a tutorial for converting old tests that use Test::Builder or Test::More to the newer Test2 way of doing things. .SS "ADVANCED PLANNING" .IX Subsection "ADVANCED PLANNING" Test2::Manual::Testing::Planning is a tutorial on the many ways to set a plan. .SS "TODO TESTS" .IX Subsection "TODO TESTS" Test2::Manual::Testing::Todo is a tutorial for markings tests as TODO. .SS SUBTESTS .IX Subsection "SUBTESTS" COMING SOON. .SS COMPARISONS .IX Subsection "COMPARISONS" COMING SOON. .PP \fISIMPLE COMPARISONS\fR .IX Subsection "SIMPLE COMPARISONS" .PP COMING SOON. .PP \fIADVANCED COMPARISONS\fR .IX Subsection "ADVANCED COMPARISONS" .PP COMING SOON. .SS "TESTING EXPORTERS" .IX Subsection "TESTING EXPORTERS" COMING SOON. .SS "TESTING CLASSES" .IX Subsection "TESTING CLASSES" COMING SOON. .SS TRAPPING .IX Subsection "TRAPPING" COMING SOON. .PP \fITRAPPING EXCEPTIONS\fR .IX Subsection "TRAPPING EXCEPTIONS" .PP COMING SOON. .PP \fITRAPPING WARNINGS\fR .IX Subsection "TRAPPING WARNINGS" .PP COMING SOON. .SS "DEFERRED TESTING" .IX Subsection "DEFERRED TESTING" COMING SOON. .SS "MANAGING ENCODINGS" .IX Subsection "MANAGING ENCODINGS" COMING SOON. .SS "AUTO-ABORT ON FAILURE" .IX Subsection "AUTO-ABORT ON FAILURE" COMING SOON. .SS "CONTROLLING RANDOM BEHAVIOR" .IX Subsection "CONTROLLING RANDOM BEHAVIOR" COMING SOON. .SS "WRITING YOUR OWN BUNDLE" .IX Subsection "WRITING YOUR OWN BUNDLE" COMING SOON. .SH "TOOLSET DOCUMENTATION" .IX Header "TOOLSET DOCUMENTATION" COMING SOON. .SH "PLUGIN DOCUMENTATION" .IX Header "PLUGIN DOCUMENTATION" COMING SOON. .SH "BUNDLE DOCUMENTATION" .IX Header "BUNDLE DOCUMENTATION" COMING SOON. .SH "REQUIRE DOCUMENTATION" .IX Header "REQUIRE DOCUMENTATION" COMING SOON. .SH "SEE ALSO" .IX Header "SEE ALSO" Test2::Manual \- Primary index of the manual. .SH SOURCE .IX Header "SOURCE" The source code repository for Test2\-Manual can be found at \&\fIhttps://github.com/Test\-More/Test2\-Suite/\fR. .SH MAINTAINERS .IX Header "MAINTAINERS" .IP "Chad Granum " 4 .IX Item "Chad Granum " .SH AUTHORS .IX Header "AUTHORS" .PD 0 .IP "Chad Granum " 4 .IX Item "Chad Granum " .PD .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright 2018 Chad Granum . .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP See \fIhttp://dev.perl.org/licenses/\fR