1

I am performing Black-box testing on a DLL. First API I have is connect.

connect accepts certain parameters, performs certain operations (Which include COM port and/or LAN access) and if it is first call then launches an application.

I have to call disconnect after every test to clear up what connect has done to have a clean environment.

Probem is disconnect is also a function given by same DLL and I will be testing it after this. But I don't want to depend on any other API of DLL-Under-Test during it's test.

Is there any way by which I can clear Memory allocated, Applications triggered, Port bindings by a DLL externally?

1

The way I'd structure this is as follows:

  • First, I'd test the connect method. Disconnect would then be a part of my post-test cleanup.
  • Second, I'd test the disconnect method. Connect would be part of my pre-test setup.
  • After this, I'd test other methods in the API, with connect in the pre-test setup and disconnect in the post-test cleanup.

The basic pattern would be (pseudocode)

[@test_setup]
TestSetup () {
    API.Connect()
}

[@test_teardown]
TestTeardown () {
    API.Disconnect()
}

[@test_method_no_setup] 
Test_Connect () {
    API.Connect()
    // Add assertions here
}

[@test_method_no_teardown]
Test_Disconnect() {
    // Connect should have run as part of the setup
    API.Disconnect()
    // Add assertions here
}

[@test_method]
Test_Other() {
    // Connect should have run as part of the set up
    // Perform desired API call
    // Add assertions
    // Disconnect should run as part of the teardown
}

The exact structure will depend on your testing framework and how it handles setups and teardowns.

Another option is simply to place the connect into your setup and disconnect into your teardown after you've verified both and recorded the results somewhere. At that point you can include some basic exception handling in the setup/teardown methods to report an error if after running API.Connect() the dll doesn't report that it is connected (similar for disconnect).

| improve this answer | |
  • I am following exact same method!! (Cheers to Python) But the problem is I want to avoid disconnect in Tear Down... and that's what I am searching for alternatives. Otherwise, this is the last option I have! – Swanand Oct 6 '15 at 12:14
  • You can ask the developers if externally killing the process will free the resources cleanly. If the answer is yes, you should be able to use something like pskill (processname) to force disconnect. If not, this is your option. – Kate Paulk Oct 6 '15 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.