#DistZilla: +PodWeaver
#PODNAME: Lab::Measurement::Developer::Testing
#ABSTRACT: Using mock instruments for testing

__END__

=pod

=encoding utf-8

=head1 NAME

Lab::Measurement::Developer::Testing - Using mock instruments for testing (deprecated)

=head1 VERSION

version 3.899

=head1 Using mock instruments for testing.

=head2 Connection logging.

You can monitor all method calls to the interface defined in Connection.pm. To
do this, you use a C<Log> connection:

 my $instr = Instrument('Agilent34410A', {
           connection_type => 'LinuxGPIB::Log',
	   logfile => 'mylogfile.yml'
           gpib_address => 17});

This will log all calls to the connection's methods:

=over

=item Clear

=item Write

=item Read

=item Query

=item BrutalRead

=item LongQuery

=item BrutalQuery

=item timeout

=item block_connection

=item unblock_connection

=item is_blocked

=back

This information is then stored in C<mylogfile.yml>. The contents of this file
might look like this: 

 ---
 id: 0
 method: is_blocked
 retval: 0
 ---
 command: FUNCTION 'volt:ac'
 id: 1
 method: Write
 retval: 1
 ---
 id: 2
 method: is_blocked
 retval: 0
 ---
 command: FUNCTION?
 id: 3
 method: Query
 retval: '"VOLT:AC"'
 ---
 command: '*RST'
 id: 4
 method: Write
 retval: 1

For each call, we log the method name and the return value. Some methods
receive additional parameters, like the command sent to the instrument.

=head2 Mock instruments.

Mock instruments are the main ingredient when building unit tests for the
L<Lab::Measurement> package.

Using the output from a C<Log> connection, it is possible to rerun a measurement
script without using the physical instrument.

This is done by providing a previously recorded log file to the C<Mock>
connection:

 my $instr = Instrument('Agilent34410A', {
           connection_type => 'Mock',
	   logfile => 'mylogfile.yml'});

The C<Mock> connection will croak, if the calls to it deviate from
the provided log file.

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by the Lab::Measurement team; in detail:

  Copyright 2016       Simon Reinhardt
            2017       Andreas K. Huettel
            2018       Simon Reinhardt


This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
