Content deleted Content added
→showcode and templates in parameter values?: new section |
|||
(14 intermediate revisions by 6 users not shown) | |||
Line 306:
:(Template test cases are therefore not like traditional programming [[unit test]]s, where the result of some code is compared to a known expected value, and any deviation represents a failure to perform as expected. Template test cases compare and contrast two versions of the same template, and any differences in output are ''interesting'' as a means of evaluating the code changes that created those differences.) [[User:FeRDNYC|FeRDNYC]] ([[User talk:FeRDNYC|talk]]) 23:51, 6 October 2024 (UTC)
::Thanks! Sorry, I only read up to the Collapsible test cases and stopped, because I was far from wanting to collapse test cases. I did not see that how fails are alerted. [[User:Johnjbarton|Johnjbarton]] ([[User talk:Johnjbarton|talk]]) 00:01, 7 October 2024 (UTC)
== Empty testcases ==
Maybe could someone give a hint why when using this template on local wiki it is not showing comparison tables as in enwiki? I have migrated same modules and code, but it is not showing anything, just some text: [[:lt:Template:Infolentelė/testcases]] [[User:Zygimantus|Zygimantus]] ([[User talk:Zygimantus|talk]]) 21:02, 13 October 2024 (UTC)
:Click on the triangle next to "Straipsnyje naudojami šablonai:" to see the templates that are being requested. You may need to create one or more of the red templates in order to make that page work. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 00:36, 15 October 2024 (UTC)
::Yes, I thought about that, I have another page: [[:lt:Šablonas:Sąrašas be punktų/testcases]] for that, this one is minimal and does not have redlinks, still no comparison is visible, maybe some kind of unknown gadget or plugin is used? [[User:Zygimantus|Zygimantus]] ([[User talk:Zygimantus|talk]]) 11:00, 15 October 2024 (UTC)
:::I am stuck then. Maybe something in one of the modules or templates is dependent on an English-language name of a page or namespace, but that is a guess. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 12:52, 17 October 2024 (UTC)
::::Will try something, it is a pity that no error message or something is visible, maybe then it is related to CSS styles... [[User:Zygimantus|Zygimantus]] ([[User talk:Zygimantus|talk]]) 21:15, 18 October 2024 (UTC)
:::::@[[User:Zygimantus|Zygimantus]] For starters I think you need to configure https://lt.wikipedia.org/wiki/Module:Template_test_case/config for the wiki — in particular, the <code>wrappers</code> table, which the module uses to map names of templates to the functions and arguments they should use.
:::::If you notice, all of the templates related to [[Module:Template test case]] all contain the same code:
:::::<syntaxhighlight lang="mediawiki">{{#invoke:Template test case|main}}</syntaxhighlight>
:::::That's because, when the module sees it's being invoked from e.g. [[Template:Testcase table]], the <code>wrappers</code> table tells it to automatically add <code>_format = 'columns'</code> to the arguments. But on your wiki the module will never be invoked from [[Template:Testcase table]], it'll be invoked from [[lt:Šablonas:Testcase table|Šablonas:Testcase table]], and there's no wrapper mapping for that <s>template</s> page name. That's, at the very least, why your test cases are being formatted as rows instead of columns.
:::::It may not be the ''whole'' issue, but it's definitely '''an''' issue.
:::::You're also missing [[Module:Suppress categories]], which the your [[lt:Šablonas:Suppress categories|Šablonas:Suppress categories]] depends on. (Discovered by editing the testcases page, then selecting "Templates used" in the hamburger menu and looking for redlinks in the resulting list — a handy way to root out broken dependencies. There are a few others.) [[User:FeRDNYC|FeRDNYC]] ([[User talk:FeRDNYC|talk]]) 06:09, 25 October 2024 (UTC)
::::::{{Reply|FeRDNYC}} thanks. I had to translate „Template“ text in that config page. Also I wasn't aware that on local wikis these pages are not the same: [[:lt:Šablonas:Testcase table]] and [[:lt:Template:Testcase table]]. For example, if you click on those links, they will direct to same page, but on Module page it works not like that I suppose. [[User:Zygimantus|Zygimantus]] ([[User talk:Zygimantus|talk]]) 13:06, 25 October 2024 (UTC)
:::::::@[[User:Zygimantus|Zygimantus]] Yeah, the problem is that [[lt:Template:Testcase table]] acts as an '''alias''' for the canonical name — which works fine, going ''in'', because you end up at the same place. But it doesn't work in reverse, so when the module asks "What template am I being called from?", the answer will never be "Template:Testcase table"; that's not what the page is called. [[User:FeRDNYC|FeRDNYC]] ([[User talk:FeRDNYC|talk]]) 16:37, 25 October 2024 (UTC)
== Option to invoke a module ==
It would be helpful if this module could be test module output. For example instead of {{para|_template=xyz}} we had something like {{para|_module|xyz}} and {{para|_function|def}} which would pass the arguments to <code><nowiki>{{#invoke:xyz|def|...</nowiki></code> and <code><nowiki>{{#invoke:xyz/sandbox|def|...</nowiki></code> and compare the results — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 21:54, 23 January 2025 (UTC)
:@[[User:Aidan9382|Aidan9382]]: are you familiar with this module? — Martin <small>([[User:MSGJ|MSGJ]] · [[User talk:MSGJ|talk]])</small> 09:53, 18 February 2025 (UTC)
::From a quick read of the documentation, it seems to be possible to force a module test if you use {{tl|Test case nowiki}}, e.g. <syntaxhighlight lang=wikitext inline>{{Test case nowiki|template=Disambiguation|heading1=[[Module:Disambiguation]]|heading2=[[Module:Disambiguation/sandbox]]|<nowiki>{{#invoke:__TEMPLATENAME__|isDisambiguationPage|Paris}}</nowiki>}}</syntaxhighlight>. The headers it normally provides will form template links instead of module links, so you have to specify the headers manually. A little hacky, but that's at least a way you can do it right now. [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 11:20, 18 February 2025 (UTC)
== Similar module with known answer rather than live v. sandbox==
This module compares the live result to the production result. I'm interested in comparing the live result, production result, or both to a known good result. For example, I'm testing date-related templates. I have a book with a list of information about dates, such as the Gregorian calendar date, Julian calendar date, [[Julian day]], and day of the week. I'd like to compare the result from a template to what this book says the result should be.
Any suggestions? [[User:Jc3s5h|Jc3s5h]] ([[User talk:Jc3s5h|talk]]) 11:53, 18 March 2025 (UTC)
== _showcode and templates in parameter values? ==
Using another template in the tested template parameters, like this:
{{demo|sep=produces
|<nowiki>{{test case |_showcode=1 |_template=tq |_template2=!tq
|1=parameter {{nobr|with a}} template }}
</nowiki>}}
That is, the inner template is substituted before showing the code. Can this be avoided somehow (without duplicating the whole set of parameters in <code><nowiki>_code=<nowiki>{{__TEMPLATENAME__|...}}</nowiki></nowiki></code>)? — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 23:10, 6 June 2025 (UTC)
|