Warn user when mocking same item multiple times
Closed this issue · 4 comments
Warn or throw error when user mocks fx. same section twice.
For inexperienced users or when working on larger test suites it would be nice to provide easy to understand feedback as to why ones test case is perhaps not behaving as intended.
Question: Do you mean when the user mocks the same thing twice in the same test case? It's okay to mock the same resource in different test cases, as each test case may require different behaviors from that resource.
In our internal user guide it states the following known issues with mocking;
MOCK
A MOCK is global to the unit test and all test cases are affected no matter where in the unit test a MOCK is placed.
Every unit test component can only contain 10 MOCK statements
You can only MOCK the same SECTION once per unit test.
In your question you imply that mocking within a testcase is scoped for only that testcase.
I could try to produce an example (and by doing so, learn if this is still an issue)
Hi
In the original COBOL Unit test code, what @AlexKotsc states is correct for all mock types.
So the questions is rather, should COBOL-Check change this beahavior so mocks are local to the testcase, or should they still be global in the test suite.
Alternatively, should it be possible to do both global and local mocks?
So mocks defined outside a testcase are global, and mocks defined inside a testcase are local?