Home › Forums › Business Model › Unit Tests › How to test a rule set in a unit test?
- This topic has 3 replies, 2 voices, and was last updated 4 years, 3 months ago by Community Manager.
February 21, 2019 at 8:21 pm #10266Louis PaceParticipant
Consider the following three files:
<Attribute name=”x” type=”string”/>
<Attribute name=”y” type=”string” value=”(rules "WidgetRules")”/>
<Script><![CDATA[(this’y (string-append “x = ” (this’x)))]]></Script>
<TestCase name=”testCase”><![CDATA[(define t (Widget’new (: x “Apple”)))
(assert-equal “x = Apple” (t’y))
If I run the following in a scratchpad:
(define t (Widget’new (: x “Apple”)))
(logger ‘info (t’y))
Then I correctly see:
> ; 19:19:50,979 INFO [GlobalEnvironment] (NexJ Main) x = Apple
However, the unit test fails with
nexj.core.scripting.ScriptingError: Unknown rule set “WidgetRules”. (err.rules.unknownSet)
I know that a reseed is required to load rulesets, but is a reseed not done at the beginning of each unit test? How does one test a rule set in a unit test?
February 22, 2019 at 1:12 pm #10274Community ManagerKeymaster
Can you confirm what plugin version you are using for NexJ Studio?
Also can you please right click on the unit-test on the model view and check for the options “by pass recreate, cache seed data” ? I usually keep them un-checked for my local unit-testing during these kind of changes.
February 22, 2019 at 2:14 pm #10283Louis PaceParticipant
FYI, the plugin version is 13.2.84.000. However, the two options that you mentioned were the culprits. Disabling these allowed the unit test to run as expected.
Thank you very much!
February 22, 2019 at 3:19 pm #10292Community ManagerKeymaster
Glad to hear.0
- You must be logged in to reply to this topic.