How to Select a Reporter with an Environment Variable
Introduction
This guide is for selecting a Reporter at run-time, by setting the value of an Environment Variable.
Why
Sometimes different members of your team will want to use different diff programs for reporting. This feature allows everyone to have a different choice.
Alternatively, sometimes you might want to view the results of a failing test result in a different diff tool, without having to recompile your code.
Warning!
Please don’t use this as your first option, as it can add inconsistency with your build and someone else’s. For example, if you are working alone on code, you can just set your reporter in code.
It’s generally considered poor practice to use environment variables to control the behaviour of software builds and execution.
Setting the Environment Variable
The environment value APPROVAL_TESTS_USE_REPORTER
can be set, to
select the diff tool to use to show differences, if an Approval Test
fails.
For example, to set Araxis Merge as your reporter, set the
APPROVAL_TESTS_USE_REPORTER
environment value to AraxisMerge
.
Available Values
The following values of APPROVAL_TESTS_USE_REPORTER
are currently
recognised. See the next section for alternative variations on these
names.
AutoApproveIfMissingReporter
AutoApproveReporter
CIBuildOnlyReporter
ClipboardReporter
CrossPlatform::VisualStudioCodeReporter
DefaultFrontLoadedReporter
DefaultReporter
DiffReporter
EnvironmentVariableReporter
Linux::BeyondCompareReporter
Linux::KDiff3Reporter
Linux::MeldReporter
Linux::SublimeMergeReporter
Mac::AraxisMergeReporter
Mac::BeyondCompareReporter
Mac::CLionDiffReporter
Mac::DiffMergeReporter
Mac::KDiff3Reporter
Mac::KaleidoscopeReporter
Mac::P4MergeReporter
Mac::SublimeMergeReporter
Mac::TkDiffReporter
Mac::VisualStudioCodeReporter
QuietReporter
TextDiffReporter
Windows::AraxisMergeReporter
Windows::BeyondCompareReporter
Windows::CodeCompareReporter
Windows::KDiff3Reporter
Windows::SublimeMergeReporter
Windows::TortoiseDiffReporter
Windows::TortoiseGitDiffReporter
Windows::VisualStudioCodeReporter
Windows::WinMergeReporter
(See snippet source)
Acceptable Variations
A fully qualified name is:
Windows::AraxisMergerReporter
This breaks down in to:
{Windows::}{AraxisMerger}{Reporter}
or:
{OS::}{Program}{Reporter}
{OS::}
This is optional: it is one of
Mac::
,Linux::
andWindows::
and will be inferred if left outSome reporters, such as
AutoApproveReporter
, don’t have this component.
{Program}
This is required.
{Reporter}
This is optional, and is added if missing.
So, for example, on Windows, you can select
Windows::AraxisMergerReporter
by setting
APPROVAL_TESTS_USE_REPORTER
to any of the following values:
Windows::AraxisMergerReporter
Windows::AraxisMerge
AraxisMergerReporter
AraxisMerge
Other Information
This environment value is ignored on Continuous Integration builds.