SourceForge: csvdiff/csvdiff: changeset 95:03c2fabcabd1
Test für "Abweichungsverhältnis" erstellt
authorRoland Schmitz <r-sch@users.sourceforge.net>
Tue Oct 06 20:44:07 2009 +0200 (2 months ago)
changeset 9503c2fabcabd1
parent 94 9c689db68a6d
child 96 f9808ffe096f
Test für "Abweichungsverhältnis" erstellt
err
out
t/a_e_s_c_k_r.t
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/err	Tue Oct 06 20:44:07 2009 +0200
     1.3 @@ -0,0 +1,4 @@
     1.4 +
     1.5 +WARNING: Empty lines are IGNORED, they are not counted etc., take care of linenumbers!
     1.6 +  Expected Result contains 3 empty lines.
     1.7 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/out	Tue Oct 06 20:44:07 2009 +0200
     2.3 @@ -0,0 +1,49 @@
     2.4 +Record with key "200100500" is different:
     2.5 +Actual line 7 compared with Expected line 8
     2.6 + Difference in field no.: 11 - field name: Dat_Rueckgabe
     2.7 +  Actual   > 2005-12-20 <
     2.8 +  Expected > 2005-12-19 <
     2.9 +
    2.10 +-------------------------------------------------------------------------------
    2.11 +
    2.12 +Record with key "200101001" is different:
    2.13 +Actual line 2 compared with Expected line 7
    2.14 + Difference in field no.: 08 - field name: Geburtsort
    2.15 +  Actual   > THIS IS A TOP TOOL     <
    2.16 +  Expected >   This is a TOP tool  <
    2.17 +  Position = ^
    2.18 +
    2.19 + Difference in field no.: 12 - field name: VeraerbeitungMM
    2.20 +  Actual   > 99 <
    2.21 +  Expected > 98 <
    2.22 +   Ratio      > 0.98989898989899 <
    2.23 +   Difference > -1 <
    2.24 +
    2.25 +-------------------------------------------------------------------------------
    2.26 +
    2.27 +Record with key "230101901" is different:
    2.28 +Actual line 1 compared with Expected line 5
    2.29 + Difference in field no.: 05 - field name: GebNachname
    2.30 +  Actual   > Dummy  Dummy <
    2.31 +  Expected >   dummy dummy <
    2.32 +
    2.33 +-------------------------------------------------------------------------------
    2.34 +
    2.35 +Record with key "300100100" is different:
    2.36 +Actual line 5 compared with Expected line 9
    2.37 + Difference in field no.: 07 - field name: Namenszusatz
    2.38 +  Actual   > this is a very very long stringt which contains a double Space here <
    2.39 +  Expected > this is a very very long stringt which contains a double  space here <
    2.40 +  Position =                                                          ^
    2.41 +
    2.42 +-------------------------------------------------------------------------------
    2.43 +
    2.44 +Record with Key: "bar_1" exists only in expected result exp.csv, line 1
    2.45 +
    2.46 +-------------------------------------------------------------------------------
    2.47 +
    2.48 +Record with Key: "bar_xyz" exists only in actual result act.csv, line 8
    2.49 +
    2.50 +-------------------------------------------------------------------------------
    2.51 +
    2.52 +Record with Key: "barbar" exists only in expected result exp.csv, line 6
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/t/a_e_s_c_k_r.t	Tue Oct 06 20:44:07 2009 +0200
     3.3 @@ -0,0 +1,95 @@
     3.4 +#!/usr/bin/perl
     3.5 +use strict;
     3.6 +use warnings;
     3.7 +
     3.8 +use vars qw($expected $expected_error);
     3.9 +
    3.10 +use Test::More tests => 3;
    3.11 +#use Test::More qw(no_plan);
    3.12 +use Test::LongString;
    3.13 +use IPC::Open3;
    3.14 +
    3.15 +#use Test::Harness;
    3.16 +#$Test::Harness::verbose=1;
    3.17 +
    3.18 +my $command = q|./csvdiff.pl -e exp.csv -a act.csv -s ";" -c col_names.csv -k 2 -r 12|;
    3.19 +
    3.20 +my $input;
    3.21 +my $pid = open3( $input, \*OUT, \*ERROR, $command );
    3.22 +waitpid( $pid, 0 );
    3.23 +my $rc = $? >> 8;;
    3.24 +close $input;
    3.25 +
    3.26 +my $output = do { local $/; <OUT> };
    3.27 +my $error = do { local $/; <ERROR> };
    3.28 +
    3.29 +#print "=" x 73, "\n$output\n", "=" x 73, "\n";
    3.30 +
    3.31 +diag( "Bei diesem Test wird der Spalten/Feld-Trenner, die Spaltennamen und eine Key-Spalte angegeben. Darüberhinaus wird das Abweichungsverhältnis berechnet."); #TAP Kommetar Ausgabe
    3.32 +
    3.33 +cmp_ok($rc, '==', 0, "Überprüfe der Returncode von csvdiff." );
    3.34 +is_string( $output, $expected, "Überpüfe ob das Vergleichsergebnis dem erwarteten entspricht.\n>> $command << wurde aufgerufen" );
    3.35 +is_string( $error, $expected_error, "Überprüfe ob ggf. ausgegebene Warnungen oder Fehler den erwarteten entsprechen.\n>> $command << wurde aufgerufen" );
    3.36 +
    3.37 +#Hier werden die Erwarteten Ergebnisse definiert
    3.38 +BEGIN {
    3.39 +
    3.40 +$expected_error = <<"HERE";
    3.41 +
    3.42 +WARNING: Empty lines are IGNORED, they are not counted etc., take care of linenumbers!
    3.43 +  Expected Result contains 3 empty lines.
    3.44 +
    3.45 +HERE
    3.46 +
    3.47 +$expected = <<"HERE";
    3.48 +Record with key "200100500" is different:
    3.49 +Actual line 7 compared with Expected line 8
    3.50 + Difference in field no.: 11 - field name: Dat_Rueckgabe
    3.51 +  Actual   > 2005-12-20 <
    3.52 +  Expected > 2005-12-19 <
    3.53 +
    3.54 +-------------------------------------------------------------------------------
    3.55 +
    3.56 +Record with key "200101001" is different:
    3.57 +Actual line 2 compared with Expected line 7
    3.58 + Difference in field no.: 08 - field name: Geburtsort
    3.59 +  Actual   > THIS IS A TOP TOOL     <
    3.60 +  Expected >   This is a TOP tool  <
    3.61 +  Position = ^
    3.62 +
    3.63 + Difference in field no.: 12 - field name: VeraerbeitungMM
    3.64 +  Actual   > 99 <
    3.65 +  Expected > 98 <
    3.66 +   Ratio      > 0.98989898989899 <
    3.67 +   Difference > -1 <
    3.68 +
    3.69 +-------------------------------------------------------------------------------
    3.70 +
    3.71 +Record with key "230101901" is different:
    3.72 +Actual line 1 compared with Expected line 5
    3.73 + Difference in field no.: 05 - field name: GebNachname
    3.74 +  Actual   > Dummy  Dummy <
    3.75 +  Expected >   dummy dummy <
    3.76 +
    3.77 +-------------------------------------------------------------------------------
    3.78 +
    3.79 +Record with key "300100100" is different:
    3.80 +Actual line 5 compared with Expected line 9
    3.81 + Difference in field no.: 07 - field name: Namenszusatz
    3.82 +  Actual   > this is a very very long stringt which contains a double Space here <
    3.83 +  Expected > this is a very very long stringt which contains a double  space here <
    3.84 +  Position =                                                          ^
    3.85 +
    3.86 +-------------------------------------------------------------------------------
    3.87 +
    3.88 +Record with Key: "bar_1" exists only in expected result exp.csv, line 1
    3.89 +
    3.90 +-------------------------------------------------------------------------------
    3.91 +
    3.92 +Record with Key: "bar_xyz" exists only in actual result act.csv, line 8
    3.93 +
    3.94 +-------------------------------------------------------------------------------
    3.95 +
    3.96 +Record with Key: "barbar" exists only in expected result exp.csv, line 6
    3.97 +HERE
    3.98 +}