suransys / omnistap

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

Mock object is not created if testcase resides in different library #6

Closed Frogli closed 6 years ago

Frogli commented 6 years ago

When you use the function Jump to counterpart from a production class the first time from that class a testcase class is made. In the $setup of that newly made class an instance irMock is create from the production class. Unfortunately this is not happening when the testclasses are in a separate library

Steps to reproduce

  1. Open the method editor of a production class which do not have a testclass counterpart
  2. Click in the TAP menu on Jump to counterpart
  3. Method editor of the new test class is opened. Click the method $setup in the method list
barkingfoodog commented 6 years ago

Does it make a difference if the testing library is open or not when you invoke Jump to counterpart?

Frogli commented 6 years ago

It makes no difference. I just tested both scenarios

barkingfoodog commented 6 years ago

I tried reproducing this, but it's working properly for me.

Would you please throw a breakpoint at omnistap.ogTAPMenuController.$_addTestClass().20 and step into $cinst.$_doesLibraryUseSeparateTestLibary()? Does this method return kTrue in your environment?

Frogli commented 6 years ago

All right, thanks for giving this clue. I got it working. I did the following:

  1. Made sure that of both libraries the Startup_task is running
  2. [lib]_Tests.Startup_Task.$superclass should have the value omnistap.kgTAPTask
  3. And should have overridden the method Startup_Task.$useSeparateTestLibrary with the code line Quit method kTrue

Actually just like the wiki says about this... @barkingfoodog You did not made any changes to the libraries before trying to reproduce my problem?

Side note: I had to make the same adjustments for the production library. Otherwise I could not run the test with the shortcut Cmd+Shift+R. Without them the UnitTest window is shown with a yellow output button. Not sure these adjustments are as it should be. Either one should inherit omnistap.kgTAPTask or not?

barkingfoodog commented 6 years ago

@Frogli I created a new production and testing library to try and replicate this. Are you working with an example? Im not sure what you mean by "made any changes to the libraries".

If you're running the tests from a separate testing library, it would be ideal that you don't have to subclass the primary library's Startup_Task from omnistap.kgTAPTask. However, that might be required to get the Jump to Counterpart command to work.

Frogli commented 6 years ago

Oh sorry, I thought I mentioned a sample, but apparently not. I used the repository OmnisTapCliSeparateLib as an example.

I used this example also to run the test from the separate library and experienced what I mentioned in my last comment.

barkingfoodog commented 6 years ago

Ah, now I follow. :) Yes, setting zCarShop_tests.Startup_Task to subclass omnistap.kgTAPTask and setting $useSeparateTestLibrary allows the jump to work. One caveat is that the task for the test library should be running so OmnisTAP can call $useSeparateTestLibrary(). I added a note to the wiki to explain this.