Thanks Raj ... and thanks for the link to your Excel add-in!
Original Message:
Sent: Tue March 14, 2023 08:50 AM
From: Raj Rao
Subject: how to unit test individual rule
Hi Peter,
Completely agree with your division of testing into IT and business testing. I did not mean to minimize the utility of Decision Runner offered by ODM -- in fact, to encourage business testing, I've created this RuleScape Lynx Excel add-in. It is completely free to use -- if you have a complex domain model, I'd strongly encourage you to use this add-in.
However, coming to the original post -- I maintain for reasons I already stated that it rarely, if ever, makes sense to test an isolated rule. In fact, that may point to the rule needing redesign. Additionally, CI/CD is an IT process and eventually you need to execute all IT tests and business tests as part of this process.
------------------------------
Raj Rao
Original Message:
Sent: Sat March 04, 2023 03:08 AM
From: Peter Warde
Subject: how to unit test individual rule
Hi Raj,
Testing can be divided into 2 parts - IT and business testing. IT testing is for errors, and exceptions such as NPEs. Business testing is for business correctness.
The amount of business testing of a ruleset is a business requirement. Some decisions are more valuable or critical than others; some rules in a decision may be so too. Hence testing of stand-alone rules may be required. The level of test coverage must be defined by the business upfront based on risk and resources. When you have a large ruleset with decision tables with many rows it might be not possible to test all rules, all conditions in rules. So the business might adopt a test strategy based on focusing or sampling, and accept some risk.
With regard to JUnit, business testing cannot done with code testing fraemworks as business users do not understand them. That's why ODM provides Decision Runner. Business testing is best done by business users using Decision Center and Decision Runner. Once the tests are created developers can automated the tests for CI/CD using the ODM REST APIs as described here.
Peter
------------------------------
Peter Warde
peterwarde@rulearchitect.com
Original Message:
Sent: Wed March 01, 2023 11:21 PM
From: Raj Rao
Subject: how to unit test individual rule
Goh,
What use case do you have in mind? Are you interested in testing a rule in the absence of other rules, or do you just want to ensure that each rule is thoroughly tested as part of you CI/CD process?
Typically, it is not worthwhile to test stand-alone rules because:
- a well designed rule is very simple, to the point of being trivial
- the execution of a rule depends on the context (such as ruleflow, ruleset variables, etc.) and a stand-alone rule rarely makes sense from an execution standpoint. What is important is to test interactions among rules.
Therefore, best practice is to test the entire ruleset, but have well designed test cases (built using Java / JSON) to activate and execute each individual rule. A rule-of-thumb is to have 2 positive and 2 negative test cases that test each individual rule. Use a JUnit-based test framework to execute them and use the rule trace to ensure that the rule is being triggered where appropriate. This suite of test cases should be executed as part of your CI/CD process.
------------------------------
Raj Rao
Original Message:
Sent: Tue February 28, 2023 01:24 AM
From: Goh Kian Seng
Subject: how to unit test individual rule
Hello,
i know we can use test suite to test the ruleset.
but how do we unit test individual rule? how to do trigger CICD to unit test the rules?
it seem like there is not so obvious way of doing it.
------------------------------
Goh Kian Seng
------------------------------