suransys / omnistap

Unit testing framework for Omnis Studio
MIT License
15 stars 7 forks source link

Testing methods with Task variables if test methods in separate library #10

Closed Frogli closed 6 years ago

Frogli commented 6 years ago

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:

  1. Copy the to libraries to the Omnis Studio/startup folder
  2. Rename the libraries so that the are loaded after the omniscli and omnistap libraries (e.g. zMockTaskVar and zMockTaskVarTest
  3. 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

Link to the Demo library: https://github.com/frogli-omnis/MockTaskVar

barkingfoodog commented 6 years ago

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.