<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=LuaAPI%2Funit_test</id>
	<title>LuaAPI/unit test - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=LuaAPI%2Funit_test"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;action=history"/>
	<updated>2026-11-16T18:41:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=72719&amp;oldid=prev</id>
		<title>Laela at 18:05, 18 April 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=72719&amp;oldid=prev"/>
		<updated>2024-04-18T18:05:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:05, 18 April 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The outcome of a unit test is determined by the first failed assert or the first call to &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039;() or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;(). All tests must call at least one of &amp;#039;&amp;#039;&amp;#039;fail&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;, otherwise they will never end. A common idiom is to call &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; at the end of the test.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The outcome of a unit test is determined by the first failed assert or the first call to &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039;() or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;(). All tests must call at least one of &amp;#039;&amp;#039;&amp;#039;fail&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;, otherwise they will never end. A common idiom is to call &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; at the end of the test.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Functions ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== unit_test.fail ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== unit_test.fail ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Laela</name></author>
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=69792&amp;oldid=prev</id>
		<title>Celtic Minstrel: Note that it&#039;s not even manually loadable outside [test]</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=69792&amp;oldid=prev"/>
		<updated>2022-07-25T06:08:13Z</updated>

		<summary type="html">&lt;p&gt;Note that it&amp;#039;s not even manually loadable outside [test]&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 06:08, 25 July 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The &amp;lt;tt&amp;gt;unit_test&amp;lt;/tt&amp;gt; module contains functions for writing unit tests that can be run using Wesnoth&#039;s &amp;lt;tt&amp;gt;--unit&amp;lt;/tt&amp;gt; command-line option (or its abbreviated form &amp;lt;tt&amp;gt;-u&amp;lt;/tt&amp;gt;). The module is only loaded in scenarios defined using a &amp;lt;tt&amp;gt;[test]&amp;lt;/tt&amp;gt; tag.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The &amp;lt;tt&amp;gt;unit_test&amp;lt;/tt&amp;gt; module contains functions for writing unit tests that can be run using Wesnoth&#039;s &amp;lt;tt&amp;gt;--unit&amp;lt;/tt&amp;gt; command-line option (or its abbreviated form &amp;lt;tt&amp;gt;-u&amp;lt;/tt&amp;gt;). The module is only loaded in scenarios defined using a &amp;lt;tt&amp;gt;[test]&amp;lt;/tt&amp;gt; tag&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. At present, there is no way to load it in other scenarios&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The outcome of a unit test is determined by the first failed assert or the first call to &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039;() or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;(). All tests must call at least one of &amp;#039;&amp;#039;&amp;#039;fail&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;, otherwise they will never end. A common idiom is to call &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; at the end of the test.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The outcome of a unit test is determined by the first failed assert or the first call to &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039;() or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;(). All tests must call at least one of &amp;#039;&amp;#039;&amp;#039;fail&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;, otherwise they will never end. A common idiom is to call &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; at the end of the test.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=69680&amp;oldid=prev</id>
		<title>Celtic Minstrel: /* unit_test.fire_wml_menu_item */ This is not the wesnoth module…!</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=69680&amp;oldid=prev"/>
		<updated>2022-06-28T03:56:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;unit_test.fire_wml_menu_item: &lt;/span&gt; This is not the wesnoth module…!&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:56, 28 June 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l37&quot;&gt;Line 37:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== unit_test.fire_wml_menu_item ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== unit_test.fire_wml_menu_item ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;wesnoth&lt;/del&gt;.fire_wml_menu_item&#039;&#039;&#039;(&#039;&#039;id&#039;&#039;, &#039;&#039;location&#039;&#039;) &amp;amp;rarr; &#039;&#039;success&#039;&#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;unit_test&lt;/ins&gt;.fire_wml_menu_item&#039;&#039;&#039;(&#039;&#039;id&#039;&#039;, &#039;&#039;location&#039;&#039;) &amp;amp;rarr; &#039;&#039;success&#039;&#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Fires a WML menu item with the given ID as if the mouse were hovering the given location, and returns a boolean indicating whether an event was actually fired.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Fires a WML menu item with the given ID as if the mouse were hovering the given location, and returns a boolean indicating whether an event was actually fired.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=68277&amp;oldid=prev</id>
		<title>Celtic Minstrel: Document the unit_test module</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaAPI/unit_test&amp;diff=68277&amp;oldid=prev"/>
		<updated>2021-07-04T22:59:34Z</updated>

		<summary type="html">&lt;p&gt;Document the unit_test module&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;tright&amp;quot;&amp;gt; __TOC__ &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;unit_test&amp;lt;/tt&amp;gt; module contains functions for writing unit tests that can be run using Wesnoth&amp;#039;s &amp;lt;tt&amp;gt;--unit&amp;lt;/tt&amp;gt; command-line option (or its abbreviated form &amp;lt;tt&amp;gt;-u&amp;lt;/tt&amp;gt;). The module is only loaded in scenarios defined using a &amp;lt;tt&amp;gt;[test]&amp;lt;/tt&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
The outcome of a unit test is determined by the first failed assert or the first call to &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039;() or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;(). All tests must call at least one of &amp;#039;&amp;#039;&amp;#039;fail&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;finish&amp;#039;&amp;#039;&amp;#039;, otherwise they will never end. A common idiom is to call &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; at the end of the test.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.fail ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.fail&amp;#039;&amp;#039;&amp;#039;()&lt;br /&gt;
&lt;br /&gt;
Marks the unit test as failed.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.succeed ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.succeed&amp;#039;&amp;#039;&amp;#039;()&lt;br /&gt;
&lt;br /&gt;
Marks the unit test as successful, provided no prior assertions failed.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.finish ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.finish&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;result&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Marks the unit test as finished. The result can take on several values, the most common being &amp;#039;&amp;#039;fail&amp;#039;&amp;#039; or &amp;#039;&amp;#039;pass&amp;#039;&amp;#039;. Unless you need to use a special result, you should call either &amp;#039;&amp;#039;&amp;#039;fail&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;succeed&amp;#039;&amp;#039;&amp;#039; instead.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.log ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.log&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;prefix&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Logs a message to the Wesnoth console output, using &amp;#039;&amp;#039;&amp;#039;std_print&amp;#039;&amp;#039;&amp;#039;. The message will be of the form &amp;quot;prefix: message&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.tostring ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.tostring&amp;#039;&amp;#039;&amp;#039; &amp;amp;harr; &amp;#039;&amp;#039;function&amp;#039;&amp;#039;(&amp;#039;&amp;#039;value&amp;#039;&amp;#039;) &amp;amp;rarr; &amp;#039;&amp;#039;string&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Converts a value to a string for the purpose of outputting in assertion test failure messages. This can be called directly, and will output strings as quoted and other values as vanilla &amp;#039;&amp;#039;&amp;#039;tostring&amp;#039;&amp;#039;&amp;#039;. If you need to output some more complex value, you can override it for the special case.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.fire_wml_menu_item ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;wesnoth.fire_wml_menu_item&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;id&amp;#039;&amp;#039;, &amp;#039;&amp;#039;location&amp;#039;&amp;#039;) &amp;amp;rarr; &amp;#039;&amp;#039;success&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Fires a WML menu item with the given ID as if the mouse were hovering the given location, and returns a boolean indicating whether an event was actually fired.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; If used with menu items that have &amp;#039;&amp;#039;&amp;#039;needs_select=yes&amp;#039;&amp;#039;&amp;#039;, be sure to select a unit first with &amp;#039;&amp;#039;&amp;#039;wesnoth.units.select&amp;#039;&amp;#039;&amp;#039;, otherwise the game might crash.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;condition&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that the specified condition is true. The message should describe the meaning of the &amp;#039;&amp;#039;condition&amp;#039;&amp;#039; somehow; the simplest way to do this is to copy-paste the condition as a string.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_equal ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_equal&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is equal to &amp;#039;&amp;#039;b&amp;#039;&amp;#039;. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_not_equal ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_not_equal&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is not equal to &amp;#039;&amp;#039;b&amp;#039;&amp;#039;. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_approx_equal ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_approx_equal&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;tolerance&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is approximately equal to &amp;#039;&amp;#039;b&amp;#039;&amp;#039; within the specified tolerance. Use this if you need to compare real (ie floating-point) numbers. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_greater ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_greater&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is greater than &amp;#039;&amp;#039;b&amp;#039;&amp;#039;. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_greater_equal ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_greater_equal&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is greater than or equal to &amp;#039;&amp;#039;b&amp;#039;&amp;#039;. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_less ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_less&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is less than &amp;#039;&amp;#039;b&amp;#039;&amp;#039;. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_less_equal ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_less_equal&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;a&amp;#039;&amp;#039;, &amp;#039;&amp;#039;b&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that &amp;#039;&amp;#039;a&amp;#039;&amp;#039; is less than or equal to &amp;#039;&amp;#039;b&amp;#039;&amp;#039;. The message should describe the meaning of &amp;#039;&amp;#039;a&amp;#039;&amp;#039; and &amp;#039;&amp;#039;b&amp;#039;&amp;#039; somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_in_range ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_in_range&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;value&amp;#039;&amp;#039;, &amp;#039;&amp;#039;minimum&amp;#039;&amp;#039;, &amp;#039;&amp;#039;maximum&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Asserts that &amp;#039;&amp;#039;value&amp;#039;&amp;#039; is within the range [&amp;#039;&amp;#039;minimum&amp;#039;&amp;#039;, &amp;#039;&amp;#039;maximum&amp;#039;&amp;#039;] (that is, inclusive of both ends). The messag should describe the meaning of &amp;#039;&amp;#039;value&amp;#039;&amp;#039; somehow. If &amp;#039;&amp;#039;minimum&amp;#039;&amp;#039; and &amp;#039;&amp;#039;maximum&amp;#039;&amp;#039; are expressions, it should describe them too.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_contains ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_contains&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;source&amp;#039;&amp;#039;, &amp;#039;&amp;#039;fragment&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Asserts that the &amp;#039;&amp;#039;source&amp;#039;&amp;#039; string contains the &amp;#039;&amp;#039;fragment&amp;#039;&amp;#039; string as a substring. The message should describe the meaning of these strings somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_nothrow ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_nothrow&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;function&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that the &amp;#039;&amp;#039;function&amp;#039;&amp;#039; runs without raising an error. The function is run in a protected context, so even if it raises an error, the test will continue. The message should describe the function somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_throws ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_throws&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;function&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that the &amp;#039;&amp;#039;function&amp;#039;&amp;#039; raises an error when run. The function is run in a protected context, so even if it raises an error, the test will continue. The message should describe the function somehow.&lt;br /&gt;
&lt;br /&gt;
=== unit_test.assert_throws_with ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;unit_test.assert_throws_with&amp;#039;&amp;#039;&amp;#039;(&amp;#039;&amp;#039;error&amp;#039;&amp;#039;, &amp;#039;&amp;#039;function&amp;#039;&amp;#039;, &amp;#039;&amp;#039;message&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Assert that the &amp;#039;&amp;#039;function&amp;#039;&amp;#039; raises an error when run and that the error raised either contains &amp;#039;&amp;#039;error&amp;#039;&amp;#039; as a substring or compares equal to &amp;#039;&amp;#039;error&amp;#039;&amp;#039;. The function is run in a protected context, so even if it raises an error, the test will continue. The message should describe the function somehow.&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Celtic Minstrel</name></author>
	</entry>
</feed>