Item5911: Unit tests must work with trunk and TWikiRelease04x02
Priority: Urgent
Current State: Closed
Released In: 1.0.0
Target Release: patch
Currently, unit tests work only with trunk code. It should work with both TWikiRelease04x02 and trunk (and also with older versions).
--
TWiki:Main/GilmarSantosJr - 10 Aug 2008
I added an abstraction layer composed of two classes:
Unit::Request
and
Unit::Response
. Tests should use theses instead of
CGI
and
TWiki::Request
, so the test works with both 4.x and trunk code.
I also added two fields in
TWikiFnTestCase
:
request
and
response
, so derived classes can always use
$this->{request}
and
$this->{response}
.
Calls to
Unit::Response::new
must be made
after calling
TWiki::new
.
I tested with trunk and TWikiRelease04x02. There were some errors with the last: tests that verify new features added to trunk. This is not critical, since test compatibility must exist to test plugins and not core code.
I'll update documentation before close this item.
--
TWiki:Main.GilmarSantosJr - 18 Aug 2008
trunk
is almost done and default plugins almost all updated. I need to update
TWiki:Codev.TestCasesTutorial, but first I don't know if I should commit changes to TWikiRelease04x02 branch.
I'm concerned with plugin developers: they should be able to test their plugins with trunk and other releases. To test a plugin with trunk and 4.2, for example, it's needed to take UnitTestContrib from trunk to test with 4.2, what makes me think that changes should be committed to TWikiRelease04x02, but then it should be ported to all earlier versions that support tests...
What do you think?
--
TWiki:Main.GilmarSantosJr - 29 Sep 2008
We had a talk at twiki-dev mailing list:
Gilmar:
Since a while I'm working on "Item5911: Unit tests must work with trunk and
TWikiRelease04x02"[1]
I think it's done: there is Unit::Request and Unit::Response classes, that
just work with trunk and older releases. Calls to "new CGI" must be replaced
by "new Unit::Request". charset method must be called after "new TWiki"
and "new Unit::Response" (before, it was called like $cgi->charset, and now
it must be called $response->charset).
The main pourpose of this work is to ease plugin tests with different TWiki
releases. So, my question is: should I commit changes made to UnitTestContrib
to TWikiRelease04x02 AND all older releases? There is a little problem with
this approach: there are new core unit tests that will fail (they test new
features). But for the sole pourpose of testing plugins it will work.
Crawford:
Ah, this old problem.
The requirement for single-branch extension development means we do extension
development in the trunk only, and that in turn means we usually only run
extension unit tests against the core in trunk. The obvious exception to this
is the set of core extensions, which includes UnitTestContrib. These
extensions must be testable against the core they are tagged with. That means
the UnitTestContrib checked into TWikiRelease04x02 must run clean against
04x02. It would be unacceptable to introduce test failures to this code. So,
either the tests of the new features has to be made conditional on the TWiki
version, or the UnitTestContrib should be checked into the trunk only.
I think you should check your UnitTestContrib changes in to trunk only.
Of course for plugins outside the core set, unit tests may already have been
recoded to use TWiki::Response. Those unit tests have to be fixed so that pass
against 04x02. The obvious thing to do is to make sure they know about
TWiki::Response and behave appropriately if it isn't there. e.g.
if (require TWiki::Response) |{
$query = new Unit::Request({...});
} else {
$query = new CGI({...});
}
So, I think it's done. I also updated
TWiki:Codev.TestCasesTutorial.