Forum Discussion

sinis's avatar
sinis
Contributor
9 months ago
Solved

TestComplete TCUnit Test

I tried to create a tcunit test and wrote a script in C++

function Main()
{
try
{
TestedApps["RunAll"]();
Delay(5000);
UnitTesting["..."]["Execute"]();
TestedApps["CloseAll"]();
}
catch(exception)
{
Log["Error"]("Exception", exception["description"]);
}
}

But whene I run this code, I am getting 

'UnitTesting' is undefined
  • I've created a simple C#  .Net 4.8 application, and I'm able to call the method HelloWord from TestComplete,

    As described in TestComplete Unit Tests - .NET Applications, you need to add AutomatedQA.TestComplete.UnitTesting.dll assembly in your project. UnitTesting will then be available. Same should apply to C++.

2 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The coding should be,

    function Main()
    {
      try
      {
        TestedApps["RunAll"]();
        Sys["WaitProcess"]("UnitTestingDemo", 10000, true);
        Delay(5000);
        UnitTesting["TCUnitTest"]["Execute"]();
        TestedApps["CloseAll"]();
      }
      catch(exception)
      {
        Log["Error"]("Exception", exception["description"]);
      }
    }

    and you must integrate unit test in your application as mentioned in Integration With Unit Testing Frameworks - Overview.

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I've created a simple C#  .Net 4.8 application, and I'm able to call the method HelloWord from TestComplete,

    As described in TestComplete Unit Tests - .NET Applications, you need to add AutomatedQA.TestComplete.UnitTesting.dll assembly in your project. UnitTesting will then be available. Same should apply to C++.