Testing/COD90101.TXT

OBJECT Codeunit 90101 Automated Test Mgt.
{
  OBJECT-PROPERTIES
  {
    Date=01/01/18;
    Time=12:00:00;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    PROCEDURE GetTests@9059229();
    VAR
      CALTestManagement@9059248 : Codeunit 130401;
      FileManagement@9059246 : Codeunit 419;
      CALTestSuite@9059244 : Record 130400;
      CALTestLine@9059243 : Record 130401;
      AllObjWithCaption@9059232 : Record 2000000058;
      TestSuiteName@9059229 : Code[10];
      ServerFileName@52102235 : Text;
      ClientFileName@52102236 : Text;
    BEGIN
      GLOBALLANGUAGE(1033);

      TestSuiteName := 'DEFAULT';
      IF NOT CALTestSuite.GET(TestSuiteName) THEN BEGIN
        CALTestSuite.INIT;
        CALTestSuite.Name := TestSuiteName;
        CALTestSuite.Description := 'Automated Testing';
        CALTestSuite.VALIDATE(Export,FALSE);
        CALTestSuite.INSERT(TRUE);
      END;

      CALTestSuite.SETRECFILTER;

      //add test codeunits
      AllObjWithCaption.SETRANGE("Object Type",AllObjWithCaption."Object Type"::Codeunit);
      AllObjWithCaption.SETRANGE("Object Subtype",'Test');
      AllObjWithCaption.SETFILTER("Object ID",'<%1|>%2',130000,150000); //only custom tests for now
      CALTestManagement.AddTestCodeunits(CALTestSuite,AllObjWithCaption);

      //add test methods
      CALTestLine.SETRANGE("Test Suite",TestSuiteName);
      CALTestLine.SETRANGE("Line Type",CALTestLine."Line Type"::Codeunit);
      CALTestLine.FINDSET;
      REPEAT
        CALTestManagement.RunSuite(CALTestLine,FALSE);
      UNTIL CALTestLine.NEXT = 0;

      CALTestLine.SETRANGE("Line Type");
      CALTestLine.FINDFIRST;
    END;

    PROCEDURE ExportResults@9059230();
    VAR
      CALTestManagement@9059248 : Codeunit 130401;
      FileManagement@9059246 : Codeunit 419;
      CALTestSuite@9059244 : Record 130400;
      CALTestLine@9059243 : Record 130401;
      AllObjWithCaption@9059232 : Record 2000000058;
      TestSuiteName@9059229 : Code[10];
      ServerFileName@52102235 : Text;
      ClientFileName@52102236 : Text;
    BEGIN
      GLOBALLANGUAGE(1033);

      ServerFileName := FileManagement.ServerTempFileName('xml');
      ClientFileName := 'C:\run\my\results.xml';

      CALTestManagement.ExportTestResults(ServerFileName,FALSE,FALSE);

      FileManagement.CopyServerFile(ServerFileName,ClientFileName,TRUE);
    END;

    BEGIN
    END.
  }
}