Forum Discussion

DKumar04's avatar
DKumar04
Contributor
6 years ago
Solved

Can I use any unit testing framework like NUnit so that I can use attributes like before/after test?

This is for desktop application automation

  • Just note:

    Natively, there are no "attributes" like exists in NUnit.  TestComplete is not, natively, a unit testing tool.  It is a UI driven functional testing tool that allows you to write code to do so.  So, any "attribute" implementation you'll have to write your own custom code to simulate the NUnit framework... the framework, itself, does NOT exist in TestComplete so you'll have to, basically, "reinvent the wheel" to implement it in TestComplete.

     

    I would recommened building a framework of your own, potentially borrowing from what NUnit does, but you don't need to go quite as far as the Unit Testing framework does.

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not sure what you're asking...  Are you asking can you call NUnit tests from within TestComplete? 

    the answer is yes, along with a number of frameworks.

    https://support.smartbear.com/testcomplete/docs/working-with/integration/unit-test-frameworks/index.html

     

    If you're asking can you write NUnit code in TestComplete... not exactly.  You can write pretty good complicated code in TestComplete but you're limited in that TestComplete is script code so single threaded and not necessarily fully OOP.  

    There are also "OnStartTest" and "OnStopTest" event handlers that you can use to execute before/after stuff.

    • DKumar04's avatar
      DKumar04
      Contributor

      I am asking that is there any way to organize my test methods in test complete by using attributes of any kind?

      so that test complete interpreter can automatically detect my test and run

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        The concept of "attributes" of a test is not part of TestComplete...  tests are not "objects" like a Unit test is in NUnit or JUnit.  In fact, a "test" in TestComplete can consist of Script, KeywordTests, etc., and even a whole bunch of code that turns into a "Test" depending upon how you code it.  So, to define a "test" is your first step... what is a test in your methodology?  Once you've defined that, you can write code around that to assign whatever functions, methods, properties, etc., you want to.

         

        In my case, I have a framework where a test consistes of a KeywordTest.  However, I use an SQL structure to determine what tests to run and determine, based upon events and other processes within the tests, whether the test is successful or not and do any "set up" or "tear down" processes that go along with that test.

        It really is all about how you're writing your code for tests.  I would say... give it a try.  Start trying things out and see what works.  If you need specific help in implementing something, feel free to ask about it.  Generally speaking, TestComplete is VERY flexible in how you implement tests and such so there probably IS a way to do what you want. So... try it.  See what you can do.  And then ask questions.