Item5911: Unit tests must work with trunk and TWikiRelease04x02

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.0
Target Release: patch
Applies To: Extension
Component: UnitTestContrib
Branches:
Reported By: TWiki:Main.GilmarSantosJr
Waiting For:
Last Change By: KennethLavrsen
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.

ItemTemplate edit

Summary Unit tests must work with trunk and TWikiRelease04x02
ReportedBy TWiki:Main.GilmarSantosJr
Codebase
SVN Range TWiki-5.0.0, Sun, 03 Aug 2008, build 17280
AppliesTo Extension
Component UnitTestContrib
Priority Urgent
CurrentState Closed
WaitingFor
Checkins TWikirev:17427 TWikirev:17528 TWikirev:17529 TWikirev:17549 TWikirev:17550 TWikirev:17567 TWikirev:17568 TWikirev:17569 TWikirev:17570
TargetRelease patch
ReleasedIn 1.0.0
Topic revision: r15 - 26 Dec 2008, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy