I run up a problem with testing methods in which task variables are accessed. The problem is that when the method is called from the mock object (iorMock) the $ctask is not the task in which the task variable is initialised.
The problem is only occurring when the the TAP tests are run from the commandlne with omniscli. Omnis Studio is expecting tSampleList in MockTaskVar_tests instead of MockTaskVar. I have created two small libraries which demonstrates the problem. I noticed that when you run test in the Omnis Studio Dev version with the OmnisTAP GUI the test passes. And apparently the $ctask is the production startup_task.
I would love to mock these task variables with the $store function, but I could not figure out how I should do this. It seems to me that the $store is expecting the task variable in the same library as the test library.
I also tried to change the active task with $activetask, but the test keeps failing. I am not sure why though. What I did see when I debugged it with a code breakpoint is that the breakpoint is hit two times. One for analysing by OmnisTAP and the second time actually runs the test? But maybe I am wrong there.
Last thing I tried was changing the loading order of the libraries by renaming the filename of the library zMockTaskVar to yMockTaskVar. But alas to no avail.
Steps to reproduce:
Copy the to libraries to the Omnis Studio/startup folder
Rename the libraries so that the are loaded after the omniscli and omnistap libraries (e.g. zMockTaskVar and zMockTaskVarTest
Run the TAP tests from the commandline
Below the terminal output. As you can see I tried this in Omnis 8.0, but got the same in 8.1.
$ /Applications/Omnis\ Studio\ 8.0.3.5\ x64.app/Contents/MacOS/bin/omniscli runtests ~/Desktop/TAP
Mon Jul 9 14:58:34 2018 Notice: Starting OmnisTAP run on MockTaskVar_tests to ~/Desktop/TAP
Mon Jul 9 14:58:34 2018 Notice: Test timing multiplier is set to 1
Mon Jul 9 14:58:34 2018 Notice: Max timing for unit tests: 5000
Mon Jul 9 14:58:35 2018 Notice: Max timing for integration tests: 90000
Mon Jul 9 14:58:35 2018 Notice: ogTAPManager.$run: ilTests linecount is 1
Mon Jul 9 14:58:35 2018 Notice: Starting up...
Running _oSampleController/$u_getSampleCount... [ fail ]
Mon Jul 9 14:58:35 2018 Debug: Preparing to create enclosing folder for ~/Desktop/TAP/oSampleController$u_getSampleCount.tap
Mon Jul 9 14:58:35 2018 Notice: running tests shutdown
Mon Jul 9 14:58:36 2018 Notice: OmnisTAP run on MockTaskVar_tests complete in 0 seconds to ~/Desktop/TAP
I re-worked how we instantiate the test classes so they'll be in the scope of the task for the library being tested. Give this a try and see how it works for you.
I run up a problem with testing methods in which task variables are accessed. The problem is that when the method is called from the mock object (
iorMock
) the$ctask
is not the task in which the task variable is initialised.Example
MockTaskVar_tests._oSampleController.$u_getSampleCount
Do ioMock.$getSampleCount() Returns sampleCount
MockTaskVar.oSampleController.$getSampleCount
Quit method tSampleList.$linecount()
The problem is only occurring when the the TAP tests are run from the commandlne with omniscli. Omnis Studio is expecting tSampleList in MockTaskVar_tests instead of MockTaskVar. I have created two small libraries which demonstrates the problem. I noticed that when you run test in the Omnis Studio Dev version with the OmnisTAP GUI the test passes. And apparently the $ctask is the production startup_task.
I would love to mock these task variables with the $store function, but I could not figure out how I should do this. It seems to me that the $store is expecting the task variable in the same library as the test library.
I also tried to change the active task with $activetask, but the test keeps failing. I am not sure why though. What I did see when I debugged it with a code breakpoint is that the breakpoint is hit two times. One for analysing by OmnisTAP and the second time actually runs the test? But maybe I am wrong there.
Last thing I tried was changing the loading order of the libraries by renaming the filename of the library zMockTaskVar to yMockTaskVar. But alas to no avail.
Steps to reproduce:
Below the terminal output. As you can see I tried this in Omnis 8.0, but got the same in 8.1.
Link to the Demo library: https://github.com/frogli-omnis/MockTaskVar