简体   繁体   中英

TemplateLibrary in fitnesse

I am a bit confused about TemplateLibrary . I understand that it is essentially to reuse boiler plate code. What I don't understand is that how does fitnesse decide which pages to include in the dropdown. If we look at the following :

在此处输入图片说明

All those highlighted appear in the dropdown. All that talk about brothers and uncles (may be I don't understand brothers and uncles concept) -

These pages act as a marker to find templates to show as available for insertion when editing a page. All children of a TemplateLibrary will be shown in the drop-down list of templates available for insertion. Unlike the other special pages, all brother and uncle TemplateLibrary pages are included. The oldest (grandest uncle) is included first. The brother, if it exists, is included last. This allows younger TemplateLibrary pages to override older ones

http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SpecialPages

To cut a long story short - How is it decided which ones are included in the dropdown?

I believe all direct children of a TemplateLibrary are included in the dropdown, as your highlighting also shows.

But there may be multiple pages called TemplateLibrary in a hierarchy of pages. The one you show is at the root of the entire wiki, but you can add others (by adding a page and giving it the special name 'TemplateLibrary'). The talk of brothers and uncles is about which template library pages are relevant on which page in the wiki (similar to how Slim handles ScenarioLibrary pages). In other words: the children of which pages are considered templates.

For instance, given the following hierarchy:

+ TemplateLibrary
++ Template1
+ WebTests
++ HomePageTest
+ SoapTests
++ TemplateLibrary
+++ Template2
++ Service1Tests
+++ TemplateLibrary
++++ Template3
+++ MyService1Test

When you add a page at the root level, or under WebTests then Template1 is available. When you add a page under SoapTests then Template1 and Template2 are available. When you add a page under Service1Tests then Template1, Template2 and Template3 are available.

If the TemplateLibrary under Service1Tests would have a child named Template1 then choosing Template1 for a new page under Service1Tests would use that page and not the one from the root level.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM