Jump to content

Testing uniGUI applications using DUnit


tappatappa

Recommended Posts

I've got to do some unit testing for my project. Is it possible to use DUnit that come shipped with RAD Studio? Has anyone found a way to start a ServerModule, MainModule AND a UniApplication object at the DUnit project startup?

 

In order to do some proper unit testing I need to be as much independent from the web GUI as possible, no user-browser interaction involved (all I need to do is a long batch execution). So Selenium is out of question.

 

Here is what my test entry point looks like

//---------------------------------------------------------------------------
// DUnit Project File.
//   Entry point of C++ project using DUnit framework.
//---------------------------------------------------------------------------

#include <System.hpp>
#pragma hdrstop
#include <tchar.h>
#include <vcl.h>

#include <UniGUIVars.hpp>
#include <GUITestRunner.hpp>

USEFORM("MyForm................
//---------------------------------------------------------------------------

#pragma link "UniGUIVars.obj"
#pragma WebAppGui

int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
  try
  {
	 Application->Initialize();
	 Uniguivars::CreateServerModule(__classid(TUniServerModule));
	 Guitestrunner::RunRegisteredTests();
  }
  catch (Exception &exception)
  {
	 Application->ShowException(&exception);
  }
  catch (...)
  {
	 try
	 {
	   throw Exception("");
	 }
	 catch (Exception &exception)
	 {
	   Application->ShowException(&exception);
	 }
  }
  return 0;
}

Now the main problem is: how do I initialize a UniApplication instance in the main thread?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...