vipm-io / vi-tester

VI Tester for LabVIEW
BSD 3-Clause "New" or "Revised" License
28 stars 26 forks source link

setUp and tearDown called based on path, not hierarchy #44

Open pktl opened 5 years ago

pktl commented 5 years ago

Hi,

I wanted to create a bunch of test classes that have a common setup/teardown procedure. So I made a generic test class which inherits from the base TestCase class. In the generic test case class, I implement the common setup and teardown procedures. Then I create specific test case classes which inherit from the generic test case class.

At least to me, there's some unexpected behaviour (or maybe it's expected and I'm using it wrong): setUp and tearDown of the generic parent class are never called.

In TestCase.lvclass:TestCase_ShellInit.viopenMethodViReference.vi, refnums for setUp and tearDown are written based on their location in the file system. They should be located based on their location in the class hierarchy, IMHO.

Is this behaviour intentional? Am I using it wrong? Of course, I could just create setUp and tearDown with nothing but a call parent node in them, but that seems rather redundant (and tedious).

Edit: I made a patch that implements the functionality (9aaf2d0e9ad4dccee10de9816486cc2fe789c7a0). If you are interested, I can create a pull request.

JamesMc86 commented 5 years ago

I was discussing this with someone last week. I agree this breaks how I expect these to work (and means I have a lot of unused setup and teardown VIs from templates that I dont use).

I've not dug deep enough to understand if there is a design reason for this choice or not.

jimkring commented 5 years ago

That was a while ago we designed this feature :-) We modeled it after python’s unittest framework, which I believe also requires child classes to call the parent’s setup and teardown explicitly. It could also be due to how these VIs are called by the framework—I think we use call by reference and not static subVI calls for setup and teardown. All of the above might be wrong, so I’d have to look and refresh my memory :-) -- Jim Sent from my mobile.

pktl commented 5 years ago

Thanks for the info! Anyway, I'm happy with my modification. So far, it works as expected :-)

JamesMc86 commented 5 years ago

I've been thinking about this. It's probably so a broken test doesn't prevent the tool from running

James McNally Director/Principal Engineer Wiresmith Technology t: 01635 597171


From: pktl notifications@github.com Sent: Thursday, August 29, 2019 8:58:49 AM To: JKISoftware/JKI-VI-Tester JKI-VI-Tester@noreply.github.com Cc: James McNally james@wiresmithtech.com; Comment comment@noreply.github.com Subject: Re: [JKISoftware/JKI-VI-Tester] setUp and tearDown called based on path, not hierarchy (#44)

Thanks for the info! Anyway, I'm happy with my modification. So far, it works as expected :-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/JKISoftware/JKI-VI-Tester/issues/44?email_source=notifications&email_token=ABBTHYE53ZA3T3MN4JUATVDQG56TTA5CNFSM4IPQFAQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5NTVTI#issuecomment-526072525, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABBTHYFWYFOYA4426ZAQPLLQG56TTANCNFSM4IPQFAQA.

pktl commented 5 years ago

Update: Unfortunately my modification doesn't quite work after all...

If the Call Parent Method is called in setUp of the SpecificTestCase, an error (Error 1 occurred at Send Notification) occurs in WaitOnTestComplete. I haven't dug deeper to find the root cause, but apparently, trying to restore proper inheritance requires a lot more work.