1WWW::Search::Test(3)  User Contributed Perl Documentation WWW::Search::Test(3)
2
3
4

NAME

6       WWW::Search::Test - utilities to aid in testing WWW::Search backends
7

SYNOPSIS

9         $oTest = new WWW::Search::Test('HotBot,Yahoo,Excite');
10         $oTest->test('HotBot', 'Kingpin', 'one', $sQuery, $TEST_RANGE, 1, 10);
11

DESCRIPTION

13       See file test.pl in the WWW-Search-HotBot distribution for a detailed
14       "real-world" example.
15

METHODS AND FUNCTIONS

17   find_websearch
18       Returns the full path of an executable WebSearch program, or undef if
19       none can be found.
20
21   new
22       Create a new WWW::Search::Test object.  All arguments are strings,
23       names of backends that this object will be able to test.  If no
24       arguments are given, will be able to test all backends.
25
26   mode
27       Set / get the test mode of this object.  If an argument is given, sets
28       the mode to that value.  Returns the current (or newly set) value.
29
30       There are three test modes available.  They are:
31
32         $MODE_INTERNAL: parse URLs out of saved pages (as a sanity check or regression test);
33         $MODE_EXTERNAL: send the query to the search engine "live", parse the results, and compare them to the previously saved results;
34       and
35         $MODE_UPDATE: send the query to the search engine "live", parse the results, and save them for future testing.
36
37   relevant_test
38       Given the name of a backend, returns true if this Test object is able
39       to test that backend.
40
41   eval_test
42       Given the name of a backend, grabs the $TEST_CASES variable from that
43       backend and evaluates it.
44
45   test
46       Run test(s) for a backend.  Arguments are, in order: name of a backend
47       to test (string, required); name of backend maintainer (string, if
48       undef $backend::MAINTAINER will be used); filename for results
49       storage/comparison (string, required); query to be sent to backend
50       (string, required); test method (required, one of the following).
51
52       Several test methods are possible:
53
54         $TEST_EXACTLY: list of URLs must match exactly (line for line, in order);
55         $TEST_BY_COUNTING: test passes if number of resulting URLs is equal;
56         $TEST_GREATER_THAN: test passes if we get more than N result URLs;
57       and
58         $TEST_RANGE: like $TEST_GREATER_THAN but constrained on both ends.
59
60   no_test
61       Prints a message stating that this backend does not have a test suite.
62       Takes two arguments, the backend name and the name of the maintainer.
63
64   not_working
65       Prints a message stating that this backend is known to be broken.
66       Takes two arguments, the backend name and the name of the maintainer.
67
68   not_working_with_tests
69       Prints a message stating that this backend is known to be broken even
70       though it has a test suite.  Takes two arguments, the backend name and
71       the name of the maintainer.
72
73   not_working_and_abandoned
74       Prints a message stating that this backend is known to be broken and is
75       not being actively maintained.  Takes two arguments, the backend name
76       and the name of the maintainer.
77
78   reset_error_count
79       Reset the counter of errors to zero.  You probably want to call this
80       before each call to test() or eval_test().
81
82   wc_l (private, not a method)
83       Given a filename, count the number of lines of text contained within
84       the file.  (I.e. simulate running UNIX command "wc -l" on a file)
85
86   diff (private, not a method)
87       Given two files, returns TRUE if contents are line-by-line different,
88       or FALSE if contents are line-by-line same.  (I.e. like the UNIX
89       command diff, but just reports true or false)
90
91   Shortcuts for running backend tests
92       WWW::Search::Test keeps its own count of test numbers, so if you want
93       to mix-and-match these functions with your own tests, use the
94       $WWW::Search::Test::iTest counter.
95
96   new_engine
97       One argument: the name of a backend suitable to be passed to
98       WWW::Search::new().  Prints 'ok' or 'not ok' and the test number.
99       Creates a WWW::Search object internally, to be used for all subsequent
100       calls to run_test and run_gui_test (see below).
101
102   tm_new_engine
103       Same as new_engine(), but uses Test::More instead of just printing
104       'ok'.
105
106   run_test
107       Three arguments: a query string, NOT escaped; a minimum number of
108       expected results; and a maximum number of expected results.  Optional
109       fourth argument: integer value to be used as the search_debug.
110       Optional fifth argument: send any true value to dump the search
111       results.  Optional sixth argument: reference to hash of search options
112       (see backend documentation).  Optional seventh argument: send any true
113       value to NOT escape the query string.
114
115       If the minimum is undef, assumes zero.  If the maximum is undef, does
116       not check.
117
118       Prints 'ok' or 'not ok' and the test number.
119
120   run_gui_test
121       Same as run_test(), but calls gui_query() instead of native_query().
122
123   tm_run_test
124       Same as run_test(), but uses Test::More rather than just printing 'ok'.
125
126       Note: If you use this function inside a TODO block, you must set global
127       variable $TODO rather than a local $TODO, and you must set the global
128       $TODO back to empty-string (or undef) at the end of your TODO block.
129       For example:
130
131         TODO:
132           {
133           $TODO = 'I have not fixed this yet';
134           tm_run_test(...);
135           $TODO = '';
136           } # end of TODO block
137
138   tm_run_test_no_approx
139       Same as tm_run_test, but does NOT check the approximate_result_count.
140
141   count_results
142       Run a query, and return the actual (not approximate) number of hits.
143       Required first argument determines which backend query method to call:
144       'gui' to call gui_query(), anything else to call native_query().
145       Remaining arguments are same as all the run_test() arguments.
146
147   skip_test
148       You can call this function instead of run_test() or run_gui_test() if
149       the current test must be skipped for any reason.
150
151   test_most_results
152       Given an arrayref of things to test, runs all those things against all
153       the results of the most-recently executed test search.
154
155
156
157perl v5.34.0                      2021-07-27              WWW::Search::Test(3)
Impressum