This brings up one interesting question “why should I put assertions inside compareResult, not anywhere in the script?”
The answer is that you can put assertions any where in the DDT script, but that will cause different behaviour if the assertion fails. If you put assertions in compareResult and the assertion fails, the AssertionFailedError will be captured and that comparison fails, but the rest script inside a test will continue executing. But if you put assertions outside of compareResult, the AssertionFailedError will lead to the failure of the current test. The exception will be recorded and the current test will be stopped. The next test will take over and execute.