Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Intraweb DUnit Testing
#11
Thanks, I tried that already, but then the call to "NewSession" results in an Access Violation.

Does anyone have a working example of using the IntraWeb Unit Testing Framework? With IW 15?

Thanks in advance!

Groetjes, Bob Swart
Reply
#12
Hi Bob,

I'll have a look and let you know the results, ASAP.

Cheers,
Reply
#13
This is the basic that is needed to create a test project:

Please notice that you need to include a ServerController and a UserSessionUnit (in case the ServerController references it) in your project:

Code:
program IWAppTest;

{$IFDEF CONSOLE_TESTRUNNER}
{$APPTYPE CONSOLE}
{$ENDIF}

uses
  SysUtils,
  IWInit,
  IWGlobal,
  ServerController,
  UserSessionUnit,
  IWApplication,
  IWServerInternalFiles,
  DUnitTestRunner;

{$R *.RES}
{$R IWData.res}

begin
  TIWServerController.SetServerControllerClass;
  gAppInit();
  try
    DUnitTestRunner.RunRegisteredTests;
  finally
    FreeAndNil(gSessions);
    TIWServerInternalFiles.Finalize;
  end;
end.

Please find the attached project


Attached Files
.zip   Test_IWApplication.zip (Size: 4.27 KB / Downloads: 5)
Reply
#14
Hi Alexandre,

Thank you, but even with that code in the .dpr file, I get an access violation when calling NewSession.

I've also attached a test project of my own. I hope I'm doing something stupid, but I've been trying for a long time now...

I'm using Delphi 11 and IW 15.2.41 (will try 15.2.42, but I do not expect that to change things).

Thanks in advance!!

Groetjes, Bob Swart


Attached Files
.zip   UnitTest.zip (Size: 91.75 KB / Downloads: 3)
Reply
#15
Hi Bob,

yes, I tested your application and there is an AV. I'm working on it and will get back to you ASAP.

Cheers,
Reply
#16
Hi Bob,

please update to the latest version. I believe it fixes that problem:

https://www.atozed.com/2021/11/intraweb-15-2-43/

Please let me know how it goes.

Cheers
Reply
#17
Thanks very much for your feedback and the fix.

I've tried version 15.2.43. The generated DUnit Test Project is still generated with the an incorrect contents of the .dpr file, but I can manually replace that with the code you sent here earlier.

However, it now complains about a missing IWTestFramework.res file, which I cannot find on my machine. Adding an empty .res file leads to an error "Cannot find internal file: SAMPLE_REQUEST". so although we no longer get the AV, I still cannot use DUnit Testing, I'm afraid...

Groetjes, Bob Swart
Reply
#18
Hi Bob,

If you download the source via https://app.atozed.com/, there is now in lib\core a file called IWTestFramework.res
Hope this is the one you are after.
Reply
#19
Hum... seems that the build is failing to include or to copy this file to the desired location.

Can you please tell me what's your Delphi version so I can check it manually?
Reply
#20
I'm using Delphi 11, the latest with the first patch applied as well. I've installed IW 15.2.43, but no IWTestFramework.res file

I seem unable to download the latest source code from https://app.atozed.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)