<commit_before>{***************************************************************************}
{                                                                           }
{           DUnitX                                                          }
{                                                                           }
{           Copyright (C) 2015 <NAME> & Contributors               }
{                                                                           }
{           <EMAIL>                                        }
{           http://www.finalbuilder.com                                     }
{                                                                           }
{                                                                           }
{***************************************************************************}
{                                                                           }
{  Licensed under the Apache License, Version 2.0 (the "License");          }
{  you may not use this file except in compliance with the License.         }
{  You may obtain a copy of the License at                                  }
{                                                                           }
{      http://www.apache.org/licenses/LICENSE-2.0                           }
{                                                                           }
{  Unless required by applicable law or agreed to in writing, software      }
{  distributed under the License is distributed on an "AS IS" BASIS,        }
{  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{  See the License for the specific language governing permissions and      }
{  limitations under the License.                                           }
{                                                                           }
{***************************************************************************}

unit DUnitX.Expert.CodeGen.Templates;

interface

{$I DUnitX.inc}

resourcestring

 { Delphi template code }

 STestDPR = 'program %0:s;'#13#10 +
 #13#10 +
 '{$IFNDEF TESTINSIGHT}'#13#10 +
 '{$APPTYPE CONSOLE}'#13#10 +
 '{$ENDIF}'+
 '{$STRONGLINKTYPES ON}'#13#10 +
 'uses'#13#10 +
 {$IFDEF USE_NS}
 '  System.SysUtils,'#13#10 +
 {$ELSE}
 '  SysUtils,'#13#10 +
 {$ENDIF}
 '{$IFDEF TESTINSIGHT}'#13#10 +
 '  TestInsight.DUnitX,'#13#10 +
 '{$ENDIF}'#13#10 +
 '  DUnitX.Loggers.Console,'#13#10 +
 '  DUnitX.Loggers.Xml.NUnit,'#13#10 +
 '  DUnitX.TestFramework;'#13#10 +
 #13#10 +
 'var'#13#10 +
 '  runner : ITestRunner;'#13#10 +
 '  results : IRunResults;'#13#10 +
 '  logger : ITestLogger;'#13#10 +
 '  nunitLogger : ITestLogger;'#13#10 +
 'begin'#13#10 +
 '{$IFDEF TESTINSIGHT}'#13#10 +
 '  TestInsight.DUnitX.RunRegisteredTests;'#13#10 +
 '  exit;'#13#10 +
 '{$ENDIF}'#13#10 +
 '  try'#13#10 +
 '    //Check command line options, will exit if invalid'#13#10 +
 '    TDUnitX.CheckCommandLine;'#13#10 +
 '    //Create the test runner'#13#10 +
 '    runner := TDUnitX.CreateRunner;'#13#10 +
 '    //Tell the runner to use RTTI to find Fixtures'#13#10 +
 '    runner.UseRTTI := True;'#13#10 +
 '    //tell the runner how we will log things'#13#10 +
 '    //Log to the console window'#13#10 +
 '    logger := TDUnitXConsoleLogger.Create(true);'#13#10 +
 '    runner.AddLogger(logger);'#13#10 +
 '    //Generate an NUnit compatible XML File'#13#10 +
 '    nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);'#13#10 +
 '    runner.AddLogger(nunitLogger);'#13#10 +
 '    runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;'#13#10 +
 #13#10 +
 '    //Run tests'#13#10 +
 '    results := runner.Execute;'#13#10 +
 '    if not results.AllPassed then'#13#10 +
 '      System.ExitCode := EXIT_ERRORS;'#13#10 +
 #13#10 +
 '    {$IFNDEF CI}'#13#10 +
 '    //We don''t want this happening when running under CI.'#13#10 +
 '    if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then'#13#10 +
 '    begin'#13#10 +
 '      System.Write(''Done.. press <Enter> key to quit.'');'#13#10 +
 '      System.Readln;'#13#10 +
 '    end;'#13#10 +
 '    {$ENDIF}'#13#10 +
 '  except'#13#10 +
 '    on E: Exception do'#13#10 +
 '      System.Writeln(E.ClassName, '': '', E.Message);'#13#10 +
 '  end;'#13#10 +
 'end.'#13#10;

 // 0 - Unit Name
 // 1 - Class Name
 // 2 - Setup/TearDown Methods - Interface
 // 3 - Sample Methods - Interface
 // 4 - Setup/TearDown Methods - Implementation
 // 5 - Sample Methods - Implementation
 STestUnit = 'unit %0:s;'#13#10 +
 #13#10 +
 'interface'#13#10 +
 'uses'#13#10 +
 '  DUnitX.TestFramework;'#13#10 +
 #13#10 +
 'type'#13#10 +
 #13#10 +
 '  [TestFixture]'#13#10 +
 '  %1:s = class(TObject) '#13#10 +
 '  public'#13#10 +
 '%2:s%3:s' +
 '  end;'#13#10 +
 #13#10 +
 'implementation'#13#10 +
 #13#10 +
 '%4:s%5:s' +
 #13#10 +
 'initialization'#13#10 +
 '  TDUnitX.RegisterTestFixture(%1:s);'#13#10 +<commit_msg>Ajustado o template, para o caso de utilizar o test insight. (#233)<commit_after>{***************************************************************************}
{                                                                           }
{           DUnitX                                                          }
{                                                                           }
{           Copyright (C) 2015 <NAME> & Contributors               }
{                                                                           }
{           <EMAIL>                                        }
{           http://www.finalbuilder.com                                     }
{                                                                           }
{                                                                           }
{***************************************************************************}
{                                                                           }
{  Licensed under the Apache License, Version 2.0 (the "License");          }
{  you may not use this file except in compliance with the License.         }
{  You may obtain a copy of the License at                                  }
{                                                                           }
{      http://www.apache.org/licenses/LICENSE-2.0                           }
{                                                                           }
{  Unless required by applicable law or agreed to in writing, software      }
{  distributed under the License is distributed on an "AS IS" BASIS,        }
{  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{  See the License for the specific language governing permissions and      }
{  limitations under the License.                                           }
{                                                                           }
{***************************************************************************}

unit DUnitX.Expert.CodeGen.Templates;

interface

{$I DUnitX.inc}

resourcestring

 { Delphi template code }

 STestDPR = 'program %0:s;'#13#10 +
 #13#10 +
 '{$IFNDEF TESTINSIGHT}'#13#10 +
 '{$APPTYPE CONSOLE}'#13#10 +
 '{$ENDIF}'+
 '{$STRONGLINKTYPES ON}'#13#10 +
 'uses'#13#10 +
 {$IFDEF USE_NS}
 '  System.SysUtils,'#13#10 +
 {$ELSE}
 '  SysUtils,'#13#10 +
 {$ENDIF}
 '{$IFDEF TESTINSIGHT}'#13#10 +
 '  TestInsight.DUnitX,'#13#10 +
 '{$ENDIF}'#13#10 +
 '  DUnitX.Loggers.Console,'#13#10 +
 '  DUnitX.Loggers.Xml.NUnit,'#13#10 +
 '  DUnitX.TestFramework;'#13#10 +
 #13#10 +
 '{$IFNDEF TESTINSIGHT}'#13#10 +
 'var'#13#10 +
 '  runner : ITestRunner;'#13#10 +
 '  results : IRunResults;'#13#10 +
 '  logger : ITestLogger;'#13#10 +
 '  nunitLogger : ITestLogger;'#13#10 +
 '{$ENDIF}'#13#10 +
 'begin'#13#10 +
 '{$IFDEF TESTINSIGHT}'#13#10 +
 '  TestInsight.DUnitX.RunRegisteredTests;'#13#10 +
 '{$ELSE}'#13#10 +
 '  try'#13#10 +
 '    //Check command line options, will exit if invalid'#13#10 +
 '    TDUnitX.CheckCommandLine;'#13#10 +
 '    //Create the test runner'#13#10 +
 '    runner := TDUnitX.CreateRunner;'#13#10 +
 '    //Tell the runner to use RTTI to find Fixtures'#13#10 +
 '    runner.UseRTTI := True;'#13#10 +
 '    //tell the runner how we will log things'#13#10 +
 '    //Log to the console window'#13#10 +
 '    logger := TDUnitXConsoleLogger.Create(true);'#13#10 +
 '    runner.AddLogger(logger);'#13#10 +
 '    //Generate an NUnit compatible XML File'#13#10 +
 '    nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);'#13#10 +
 '    runner.AddLogger(nunitLogger);'#13#10 +
 '    runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;'#13#10 +
 #13#10 +
 '    //Run tests'#13#10 +
 '    results := runner.Execute;'#13#10 +
 '    if not results.AllPassed then'#13#10 +
 '      System.ExitCode := EXIT_ERRORS;'#13#10 +
 #13#10 +
 '    {$IFNDEF CI}'#13#10 +
 '    //We don''t want this happening when running under CI.'#13#10 +
 '    if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then'#13#10 +
 '    begin'#13#10 +
 '      System.Write(''Done.. press <Enter> key to quit.'');'#13#10 +
 '      System.Readln;'#13#10 +
 '    end;'#13#10 +
 '    {$ENDIF}'#13#10 +
 '  except'#13#10 +
 '    on E: Exception do'#13#10 +
 '      System.Writeln(E.ClassName, '': '', E.Message);'#13#10 +
 '  end;'#13#10 +
 '{$ENDIF}'#13#10 +
 'end.'#13#10;

 // 0 - Unit Name
 // 1 - Class Name
 // 2 - Setup/TearDown Methods - Interface
 // 3 - Sample Methods - Interface
 // 4 - Setup/TearDown Methods - Implementation
 // 5 - Sample Methods - Implementation
 STestUnit = 'unit %0:s;'#13#10 +
 #13#10 +
 'interface'#13#10 +
 'uses'#13#10 +
 '  DUnitX.TestFramework;'#13#10 +
 #13#10 +
 'type'#13#10 +
 #13#10 +
 '  [TestFixture]'#13#10 +
 '  %1:s = class(TObject) '#13#10 +
 '  public'#13#10 +
 '%2:s%3:s' +
 '  end;'#13#10 +
 #13#10 +
 'implementation'#13#10 +
 #13#10 +
 '%4:s%5:s' +
 #13#10 +
 'initialization'#13#10 +
 '  TDUnitX.RegisterTestFixture(%1:s);'#13#10 +
{'fraction_non_alphanumeric': 0.1876818136222289, 'fraction_numerical': 0.0673086568361922, 'mean_word_length': 1.742024202420242, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 66, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '357460', 'n_tokens_mistral': 3429, 'n_tokens_neox': 3020, 'n_words': 596}