Page 1 of 1
Does PureUnit work with modules?
Posted: Tue Aug 11, 2015 6:08 pm
by Erich
I always get an error "Can't define a procedure inside another procedure" when I want to test a procedure from a module.

Re: Does PureUnit work with modules?
Posted: Tue Aug 11, 2015 9:29 pm
by freak
I must say I did not test this yet, but it should work as long as you keep the test procedures outside of the module (in the main scope). The test procedure should be able to call module code without problems.
Do you have some example code to show your problem?
Re: Does PureUnit work with modules?
Posted: Wed Aug 12, 2015 9:11 am
by Little John
freak wrote:I must say I did not test this yet, but it should work as long as you keep the test procedures outside of the module (in the main scope).
I have written several programs for testing modules with PureUnit in this way, and they all work fine.
Re: Does PureUnit work with modules?
Posted: Wed Aug 12, 2015 10:02 am
by Erich
Yes, indeed it works! Sorry, my mistake. Freak pointed me in the right direction.
Instead of this:
Code: Select all
XIncludeFile "module_unittest1.pb"
ProcedureUnitStartup start_test()
I wrote that somewhere in a larger test suite:
Code: Select all
ProcedureUnitStartup start_test()
XIncludeFile "module_unittest1.pb"
which explains the error message. The include has to be outside the test procedure.
Re: Does PureUnit work with modules?
Posted: Wed Aug 12, 2015 12:39 pm
by Little John
Erich wrote:The include has to be outside the test procedure.
Yes.
Including one or more procedures in another procedure will
never work with PB,
regardless of whether the included procedures are inside a module or not.