source: trunk/server/www/vendors/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE @ 6

Last change on this file since 6 was 6, checked in by sander, 11 years ago

Added SimpleTest? test framework

File size: 12.8 KB
Line 
1Simple Test interface changes
2=============================
3Because the SimpleTest tool set is still evolving it is likely that tests
4written with earlier versions will fail with the newest ones. The most
5dramatic changes are in the alpha releases. Here is a list of possible
6problems and their fixes...
7
8No method getRelativeUrls() or getAbsoluteUrls()
9------------------------------------------------
10These methods were always a bit weird anyway, and
11the new parsing of the base tag makes them more so.
12They have been replaced with getUrls() instead. If
13you want the old functionality then simply chop
14off the current domain from getUrl().
15
16Method setWildcard() removed in mocks
17-------------------------------------
18Even setWildcard() has been removed in 1.0.1beta now.
19If you want to test explicitely for a '*' string, then
20simply pass in new IdenticalExpectation('*') instead.
21
22No method _getTest() on mocks
23-----------------------------
24This has finally been removed. It was a pretty esoteric
25flex point anyway. It was there to allow the mocks to
26work with other test tools, but no one does this.
27
28No method assertError(), assertNoErrors(), swallowErrors()
29----------------------------------------------------------
30These have been deprecated in 1.0.1beta in favour of
31expectError() and expectException(). assertNoErrors() is
32redundant if you use expectError() as failures are now reported
33immediately.
34
35No method TestCase::signal()
36----------------------------
37This has been deprecated in favour of triggering an error or
38throwing an exception. Deprecated as of 1.0.1beta.
39
40No method TestCase::sendMessage()
41---------------------------------
42This has been deprecated as of 1.0.1beta.
43
44Failure to connect now emits failures
45-------------------------------------
46It used to be that you would have to use the
47getTransferError() call on the web tester to see if
48there was a socket level error in a fetch. This check
49is now always carried out by the WebTestCase unless
50the fetch is prefaced with WebTestCase::ignoreErrors().
51The ignore directive only lasts for test case fetching
52action such as get() and click().
53
54No method SimpleTestOptions::ignore()
55-------------------------------------
56This is deprecated in version 1.0.1beta and has been moved
57to SimpleTest::ignore() as that is more readable. In
58addition, parent classes are also ignored automatically.
59If you are using PHP5 you can skip this directive simply
60by marking your test case as abstract.
61
62No method assertCopy()
63----------------------
64This is deprecated in 1.0.1 in favour of assertClone().
65The assertClone() method is slightly different in that
66the objects must be identical, but without being a
67reference. It is thus not a strict inversion of
68assertReference().
69
70Constructor wildcard override has no effect in mocks
71----------------------------------------------------
72As of 1.0.1beta this is now set with setWildcard() instead
73of in the constructor.
74
75No methods setStubBaseClass()/getStubBaseClass()
76------------------------------------------------
77As mocks are now used instead of stubs, these methods
78stopped working and are now removed as of the 1.0.1beta
79release. The mock objects may be freely used instead.
80
81No method addPartialMockCode()
82------------------------------
83The ability to insert arbitrary partial mock code
84has been removed. This was a low value feature
85causing needless complications. It was removed
86in the 1.0.1beta release.
87
88No method setMockBaseClass()
89----------------------------
90The ability to change the mock base class has been
91scheduled for removal and is deprecated since the
921.0.1beta version. This was a rarely used feature
93except as a workaround for PHP5 limitations. As
94these limitations are being resolved it's hoped
95that the bundled mocks can be used directly.
96
97No class Stub
98-------------
99Server stubs are deprecated from 1.0.1 as the mocks now
100have exactly the same interface. Just use mock objects
101instead.
102
103No class SimpleTestOptions
104--------------------------
105This was replced by the shorter SimpleTest in 1.0.1beta1
106and is since deprecated.
107
108No file simple_test.php
109-----------------------
110This was renamed test_case.php in 1.0.1beta to more accurately
111reflect it's purpose. This file should never be directly
112included in test suites though, as it's part of the
113underlying mechanics and has a tendency to be refactored.
114
115No class WantedPatternExpectation
116---------------------------------
117This was deprecated in 1.0.1alpha in favour of the simpler
118name PatternExpectation.
119
120No class NoUnwantedPatternExpectation
121-------------------------------------
122This was deprecated in 1.0.1alpha in favour of the simpler
123name NoPatternExpectation.
124
125No method assertNoUnwantedPattern()
126-----------------------------------
127This has been renamed to assertNoPattern() in 1.0.1alpha and
128the old form is deprecated.
129
130No method assertWantedPattern()
131-------------------------------
132This has been renamed to assertPattern() in 1.0.1alpha and
133the old form is deprecated.
134
135No method assertExpectation()
136-----------------------------
137This was renamed as assert() in 1.0.1alpha and the old form
138has been deprecated.
139
140No class WildcardExpectation
141----------------------------
142This was a mostly internal class for the mock objects. It was
143renamed AnythingExpectation to bring it closer to JMock and
144NMock in version 1.0.1alpha.
145
146Missing UnitTestCase::assertErrorPattern()
147------------------------------------------
148This method is deprecated for version 1.0.1 onwards.
149This method has been subsumed by assertError() that can now
150take an expectation. Simply pass a PatternExpectation
151into assertError() to simulate the old behaviour.
152
153No HTML when matching page elements
154-----------------------------------
155This behaviour has been switched to using plain text as if it
156were seen by the user of the browser. This means that HTML tags
157are suppressed, entities are converted and whitespace is
158normalised. This should make it easier to match items in forms.
159Also images are replaced with their "alt" text so that they
160can be matched as well.
161
162No method SimpleRunner::_getTestCase()
163--------------------------------------
164This was made public as getTestCase() in 1.0RC2.
165
166No method restartSession()
167--------------------------
168This was renamed to restart() in the WebTestCase, SimpleBrowser
169and the underlying SimpleUserAgent in 1.0RC2. Because it was
170undocumented anyway, no attempt was made at backward
171compatibility.
172
173My custom test case ignored by tally()
174--------------------------------------
175The _assertTrue method has had it's signature changed due to a bug
176in the PHP 5.0.1 release. You must now use getTest() from within
177that method to get the test case. Mock compatibility with other
178unit testers is now deprecated as of 1.0.1alpha as PEAR::PHPUnit2
179should soon have mock support of it's own.
180
181Broken code extending SimpleRunner
182----------------------------------
183This was replaced with SimpleScorer so that I could use the runner
184name in another class. This happened in RC1 development and there
185is no easy backward compatibility fix. The solution is simply to
186extend SimpleScorer instead.
187
188Missing method getBaseCookieValue()
189-----------------------------------
190This was renamed getCurrentCookieValue() in RC1.
191
192Missing files from the SimpleTest suite
193---------------------------------------
194Versions of SimpleTest prior to Beta6 required a SIMPLE_TEST constant
195to point at the SimpleTest folder location before any of the toolset
196was loaded. This is no longer documented as it is now unnecessary
197for later versions. If you are using an earlier version you may
198need this constant. Consult the documentation that was bundled with
199the release that you are using or upgrade to Beta6 or later.
200
201No method SimpleBrowser::getCurrentUrl()
202--------------------------------------
203This is replaced with the more versatile showRequest() for
204debugging. It only existed in this context for version Beta5.
205Later versions will have SimpleBrowser::getHistory() for tracking
206paths through pages. It is renamed as getUrl() since 1.0RC1.
207
208No method Stub::setStubBaseClass()
209----------------------------------
210This method has finally been removed in 1.0RC1. Use
211SimpleTestOptions::setStubBaseClass() instead.
212
213No class CommandLineReporter
214----------------------------
215This was renamed to TextReporter in Beta3 and the deprecated version
216was removed in 1.0RC1.
217
218No method requireReturn()
219-------------------------
220This was deprecated in Beta3 and is now removed.
221
222No method expectCookie()
223------------------------
224This method was abruptly removed in Beta4 so as to simplify the internals
225until another mechanism can replace it. As a workaround it is necessary
226to assert that the cookie has changed by setting it before the page
227fetch and then assert the desired value.
228
229No method clickSubmitByFormId()
230-------------------------------
231This method had an incorrect name as no button was involved. It was
232renamed to submitByFormId() in Beta4 and the old version deprecated.
233Now removed.
234
235No method paintStart() or paintEnd()
236------------------------------------
237You should only get this error if you have subclassed the lower level
238reporting and test runner machinery. These methods have been broken
239down into events for test methods, events for test cases and events
240for group tests. The new methods are...
241
242paintStart() --> paintMethodStart(), paintCaseStart(), paintGroupStart()
243paintEnd() --> paintMethodEnd(), paintCaseEnd(), paintGroupEnd()
244
245This change was made in Beta3, ironically to make it easier to subclass
246the inner machinery. Simply duplicating the code you had in the previous
247methods should provide a temporary fix.
248
249No class TestDisplay
250--------------------
251This has been folded into SimpleReporter in Beta3 and is now deprecated.
252It was removed in RC1.
253
254No method WebTestCase::fetch()
255------------------------------
256This was renamed get() in Alpha8. It is removed in Beta3.
257
258No method submit()
259------------------
260This has been renamed clickSubmit() in Beta1. The old method was
261removed in Beta2.
262
263No method clearHistory()
264------------------------
265This method is deprecated in Beta2 and removed in RC1.
266
267No method getCallCount()
268------------------------
269This method has been deprecated since Beta1 and has now been
270removed. There are now more ways to set expectations on counts
271and so this method should be unecessery. Removed in RC1.
272
273Cannot find file *
274------------------
275The following public name changes have occoured...
276
277simple_html_test.php --> reporter.php
278simple_mock.php --> mock_objects.php
279simple_unit.php --> unit_tester.php
280simple_web.php --> web_tester.php
281
282The old names were deprecated in Alpha8 and removed in Beta1.
283
284No method attachObserver()
285--------------------------
286Prior to the Alpha8 release the old internal observer pattern was
287gutted and replaced with a visitor. This is to trade flexibility of
288test case expansion against the ease of writing user interfaces.
289
290Code such as...
291
292$test = &new MyTestCase();
293$test->attachObserver(new TestHtmlDisplay());
294$test->run();
295
296...should be rewritten as...
297
298$test = &new MyTestCase();
299$test->run(new HtmlReporter());
300
301If you previously attached multiple observers then the workaround
302is to run the tests twice, once with each, until they can be combined.
303For one observer the old method is simulated in Alpha 8, but is
304removed in Beta1.
305
306No class TestHtmlDisplay
307------------------------
308This class has been renamed to HtmlReporter in Alpha8. It is supported,
309but deprecated in Beta1 and removed in Beta2. If you have subclassed
310the display for your own design, then you will have to extend this
311class (HtmlReporter) instead.
312
313If you have accessed the event queue by overriding the notify() method
314then I am afraid you are in big trouble :(. The reporter is now
315carried around the test suite by the runner classes and the methods
316called directly. In the unlikely event that this is a problem and
317you don't want to upgrade the test tool then simplest is to write your
318own runner class and invoke the tests with...
319
320$test->accept(new MyRunner(new MyReporter()));
321
322...rather than the run method. This should be easier to extend
323anyway and gives much more control. Even this method is overhauled
324in Beta3 where the runner class can be set within the test case. Really
325the best thing to do is to upgrade to this version as whatever you were
326trying to achieve before should now be very much easier.
327
328Missing set options method
329--------------------------
330All test suite options are now in one class called SimpleTestOptions.
331This means that options are set differently...
332
333GroupTest::ignore() --> SimpleTestOptions::ignore()
334Mock::setMockBaseClass() --> SimpleTestOptions::setMockBaseClass()
335
336These changed in Alpha8 and the old versions are now removed in RC1.
337
338No method setExpected*()
339------------------------
340The mock expectations changed their names in Alpha4 and the old names
341ceased to be supported in Alpha8. The changes are...
342
343setExpectedArguments() --> expectArguments()
344setExpectedArgumentsSequence() --> expectArgumentsAt()
345setExpectedCallCount() --> expectCallCount()
346setMaximumCallCount() --> expectMaximumCallCount()
347
348The parameters remained the same.
Note: See TracBrowser for help on using the repository browser.