### DUnitX Setup Attribute Example Source: https://github.com/vsofttechnologies/dunitx/wiki/Setup Demonstrates the usage of the Setup attribute in DUnitX. The `TestSetup` procedure is executed before each test method within the `TTestSomething` test fixture. ```delphi [TestFixture] TTestSomething = class [Setup] procedure TestSetup; [Test] procedure Test_That_Something_Works; ... ``` -------------------------------- ### DUnitX Test Unit Structure and Registration (Delphi) Source: https://github.com/vsofttechnologies/dunitx/wiki/Getting-Started Demonstrates the basic structure of a DUnitX test unit in Delphi, including the use of attributes like TestFixture, Setup, TearDown, Test, and TestCase. It also shows how to register the test fixture in the initialization section. ```delphi unit Unit1; interface uses DUnitX.TestFramework; type [TestFixture] TMyTestObject = class(TObject) public [Setup] procedure Setup; [TearDown] procedure TearDown; // Sample Methods // Simple single Test [Test] procedure Test1; // Test with TestCase Atribute to supply parameters. [Test] [TestCase('TestA','1,2')] [TestCase('TestB','3,4')] procedure Test2(const AValue1 : Integer;const AValue2 : Integer); end; implementation initialization TDUnitX.RegisterTestFixture(TMyTestObject); end. ``` -------------------------------- ### Define Test Fixture with Setup/Teardown Methods in Delphi Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Demonstrates how to define a test fixture class using the `[TestFixture]` attribute in Delphi. It includes methods for fixture-level setup/teardown (`[SetupFixture]`, `[TeardownFixture]`) and test-level setup/teardown (`[Setup]`, `[TearDown]`), along with example test methods marked with `[Test]`. This structure helps organize and manage test resources and state. ```delphi unit MyTests; interface uses DUnitX.TestFramework; type [TestFixture('Calculator', 'Tests for calculator operations')] TCalculatorTests = class private FCalculator: TCalculator; public [SetupFixture] // Runs once before all tests in fixture procedure SetupFixture; [TeardownFixture] // Runs once after all tests in fixture procedure TeardownFixture; [Setup] // Runs before each test method procedure Setup; [TearDown] // Runs after each test method procedure TearDown; [Test] procedure TestAddition; [Test] procedure TestSubtraction; end; implementation procedure TCalculatorTests.SetupFixture; begin // Initialize resources shared across all tests FCalculator := TCalculator.Create; end; procedure TCalculatorTests.TeardownFixture; begin FCalculator.Free; end; procedure TCalculatorTests.Setup; begin FCalculator.Clear; // Reset state before each test end; procedure TCalculatorTests.TearDown; begin // Cleanup after each test if needed end; procedure TCalculatorTests.TestAddition; begin Assert.AreEqual(5, FCalculator.Add(2, 3), 'Addition failed'); end; procedure TCalculatorTests.TestSubtraction; begin Assert.AreEqual(2, FCalculator.Subtract(5, 3), 'Subtraction failed'); end; initialization TDUnitX.RegisterTestFixture(TCalculatorTests); end. ``` -------------------------------- ### Configure DUnitX Test Exit Behavior Source: https://github.com/vsofttechnologies/dunitx/wiki/Command-line-test-execution This example demonstrates how to configure the exit behavior of DUnitX tests when run from the command line. The `--exitbehaviour` option can be set to 'continue' or 'pause' to control whether the command line remains open after test execution. ```bash MyTestProj.exe -exit:continue ``` -------------------------------- ### DUnitX Test Fixture Example Source: https://github.com/vsofttechnologies/dunitx/wiki/Test Demonstrates the usage of DUnitX attributes within a test fixture. It shows how to mark methods as tests, assign categories, provide test cases with data, ignore tests, and disable tests. ```delphi [TestFixture] TMyExampleTests = class public [Test] [Category("ExampleTests")] procedure Test_Something_Works; [Test] [TestCase("Case 1", "1,2"); [TestCase("Case 2", "2,3"); procedure Test_That_Takes_Data(const AInput: Integer; AResult: Integer); [Test] [Ignore("This is broken right now")] procedure Test_That_Needs_Fixing; [Test(False)] procedure Test_That_Is_Deprecated; end; ``` -------------------------------- ### Parameterized Tests with TestCase Attribute in DUnitX Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Demonstrates how to use the [TestCase] attribute to run a single test method with multiple sets of parameters. Each TestCase attribute specifies a name and comma-separated values that are automatically coerced to the method's parameter types. This example includes tests for integer addition, string length calculation, and custom separators. ```pascal type [TestFixture] TParameterizedTests = class public [Test] [TestCase('Positive numbers', '2,3,5')] [TestCase('With zero', '0,5,5')] [TestCase('Negative numbers', '-2,-3,-5')] [TestCase('Mixed signs', '-2,5,3')] procedure TestAddition(A, B, Expected: Integer); [Test] [TestCase('Simple case', 'hello,5')] [TestCase('Empty string', ',0')] [TestCase('With spaces', 'hello world,11')] procedure TestStringLength(const Input: string; ExpectedLength: Integer); // Using semicolon as separator [Test] [TestCase('Custom separator', '1;2;3', ';')] procedure TestWithCustomSeparator(A, B, C: Integer); // String parameters with special characters [Test] [TestCase('Passwords', 'password="secret",password="secret"')] procedure TestStringsWithEquals(const Input, Expected: string); end; implementation procedure TParameterizedTests.TestAddition(A, B, Expected: Integer); begin Assert.AreEqual(Expected, A + B, Format('Failed for %d + %d', [A, B])); end; procedure TParameterizedTests.TestStringLength(const Input: string; ExpectedLength: Integer); begin Assert.AreEqual(ExpectedLength, Length(Input)); end; procedure TParameterizedTests.TestWithCustomSeparator(A, B, C: Integer); begin Assert.AreEqual(6, A + B + C); end; procedure TParameterizedTests.TestStringsWithEquals(const Input, Expected: string); begin Assert.AreEqual(Expected, Input); end; initialization TDUnitX.RegisterTestFixture(TParameterizedTests); end. ``` -------------------------------- ### Basic TestFixture Declaration Source: https://github.com/vsofttechnologies/dunitx/wiki/TestFixture Shows the minimal declaration of a TestFixture attribute for a test class. This example highlights the essential usage without additional attributes like Category or Ignore. ```delphi [TestFixture] TMyExample3Tests = class public [Test] procedure ATest; ... ``` -------------------------------- ### DUnitX TearDownFixture Example Source: https://github.com/vsofttechnologies/dunitx/wiki/TeardownFixture This example demonstrates how to use the TearDownFixture attribute in DUnitX. The TearDownFixture method is executed after all tests in the TTestSomething fixture have run. ```delphi [TestFixture] TTestSomething = class [TearDownFixture] procedure TearDownFixture; [Test] procedure Test_That_Something_Works; ... end; ``` -------------------------------- ### TestFixture with Category Attribute Source: https://github.com/vsofttechnologies/dunitx/wiki/TestFixture Demonstrates how to use the TestFixture and Category attributes to define a test fixture and assign a default category to all its tests. This example shows a basic DUnitX test class structure. ```delphi [TestFixture('ExampleFixture1','General Example Tests')] [Category('ExampleTests')] TMyExampleTests = class public [Test] procedure ATest; ... ``` -------------------------------- ### Auto-Generated Test Names with AutoNameTestCase Attribute in DUnitX Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Illustrates the use of the [AutoNameTestCase] attribute for automatically generating test names based on parameter values. This simplifies test case creation when explicit naming is not required. The example shows parameterized integer addition tests with auto-generated names. ```pascal type [TestFixture] TParameterizedTests = class public // Auto-generated test names based on parameter values [Test] [AutoNameTestCase('1,2,3')] [AutoNameTestCase('4,5,9')] [AutoNameTestCase('10,20,30')] procedure TestAutoNamed(A, B, Expected: Integer); end; implementation procedure TParameterizedTests.TestAutoNamed(A, B, Expected: Integer); begin Assert.AreEqual(Expected, A + B); end; initialization TDUnitX.RegisterTestFixture(TParameterizedTests); end. ``` -------------------------------- ### DUnitX Command Line Options Overview Source: https://github.com/vsofttechnologies/dunitx/wiki/Command-line-test-execution This section lists the available command-line options for DUnitX test execution. These options allow for specifying configuration files, hiding banners, defining output file paths, selecting tests to run, filtering by categories, and controlling logging levels. ```bash --options:value or -opt:value - Options File --hidebanner or -b - Hide the License Banner --xmlfile:value or -xml:value - XML output file path --runlist:value or -rl:value - Specify the name of a file which lists the tests to run --run:value or -r:value - Specify the tests to run, separate by commas --include:value or -i:value - Specify the categories to include --exclude:value or -e:value - Specify the categories to exclude --dontshowignored or -dsi - Don't show ignored tests --loglevel:value or -l:value - Logging Level - Information, Warning, Error --exitbehavior:value or -exit:value - Exit behavior - Continue, Pause --h or -? - Show Usage ``` -------------------------------- ### Configure DUnitX Test Runner and Loggers (Pascal) Source: https://context7.com/vsofttechnologies/dunitx/llms.txt This Pascal code demonstrates how to set up a DUnitX test runner, attach multiple loggers (console and NUnit XML), configure test execution options, and handle command-line arguments. It's essential for setting up test execution environments, especially for CI integration. ```pascal program MyTestProject; {$APPTYPE CONSOLE} uses SysUtils, DUnitX.TestFramework, DUnitX.Loggers.Console, DUnitX.Loggers.XML.NUnit, DUnitX.Loggers.XML.JUnit, MyTests in 'MyTests.pas'; var Runner: ITestRunner; Results: IRunResults; Logger: ITestLogger; NUnitLogger: ITestLogger; begin try // Check command line options TDUnitX.CheckCommandLine; // Create runner with console logger Runner := TDUnitX.CreateRunner; Runner.AddLogger(TDUnitXConsoleLogger.Create(True)); // True = verbose // Add NUnit XML logger for CI integration NUnitLogger := TDUnitXXMLNUnitFileLogger.Create( TDUnitX.Options.XMLOutputFile // From command line or default ); Runner.AddLogger(NUnitLogger); // Configure runner Runner.FailsOnNoAsserts := True; // Fail tests with no assertions // Execute tests Results := Runner.Execute; // Report results if not Results.AllPassed then System.ExitCode := EXIT_ERRORS; // Optional: Pause for user input if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then begin Write('Press Enter to exit...'); Readln; end; except on E: Exception do begin Writeln(E.ClassName, ': ', E.Message); System.ExitCode := EXIT_ERRORS; end; end; end. // Command line usage: // MyTestProject.exe -h # Show help // MyTestProject.exe -xml:results.xml # Output NUnit XML // MyTestProject.exe -r:TestClass.TestMethod # Run specific test // MyTestProject.exe -i:FastTests # Include category // MyTestProject.exe -e:SlowTests # Exclude category // MyTestProject.exe -exit:pause # Pause after tests // MyTestProject.exe -b # Hide banner // MyTestProject.exe -l:Warning # Set log level ``` -------------------------------- ### DUnitX Assert: Equality and Identity Checks Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Demonstrates how to use DUnitX's Assert methods for checking equality between values (integers, strings, floats with tolerance, booleans, arrays) and object identity. ```Pascal procedure TAssertExamples.TestEqualityAssertions; var Obj1, Obj2: TObject; List1, List2: TArray; begin // Basic equality Assert.AreEqual(42, 42, 'Integers should be equal'); Assert.AreEqual('hello', 'hello', 'Strings should be equal'); Assert.AreEqual(3.14, 3.14, 0.001, 'Floats with tolerance'); Assert.AreEqual(True, True, 'Booleans should match'); // Not equal Assert.AreNotEqual(1, 2, 'Should be different'); Assert.AreNotEqual('foo', 'bar'); // Object identity Obj1 := TObject.Create; Obj2 := Obj1; try Assert.AreSame(Obj1, Obj2, 'Should be same object'); finally Obj1.Free; end; // Generic equality for arrays List1 := [1, 2, 3]; List2 := [1, 2, 3]; Assert.AreEqual>(List1, List2, 'Arrays should match'); end; ``` -------------------------------- ### DUnitX Assert: String Manipulation and Matching Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Covers DUnitX Assert methods for string validation, including checking prefixes, suffixes, substring presence, case-insensitive comparisons, and regular expression matching. Also includes a method for detailed diff reporting. ```Pascal procedure TAssertExamples.TestStringAssertions; begin Assert.StartsWith('Hello', 'Hello World', 'Should start with Hello'); Assert.EndsWith('World', 'Hello World', 'Should end with World'); Assert.Contains('Hello World', 'lo Wo', 'Should contain substring'); Assert.DoesNotContain('Hello World', 'xyz', 'Should not contain xyz'); // Case insensitive Assert.AreEqual('HELLO', 'hello', True, 'Case insensitive match'); // Regex matching Assert.IsMatch('\d+', 'abc123def', 'Should match digits pattern'); // Detailed diff on failure Assert.NoDiff('expected text', 'expected text', 'Strings should match'); end; ``` -------------------------------- ### DUnitX Assert: Exception Handling Verification Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Demonstrates DUnitX Assert methods for verifying exception handling in tests. Includes checks for specific exceptions, exceptions with messages, descendant exceptions, any exception, and ensuring no exception is raised. ```Pascal procedure TAssertExamples.TestExceptionAssertions; begin // Expect specific exception Assert.WillRaise( procedure begin raise EArgumentException.Create('Test'); end, EArgumentException, 'Should raise EArgumentException' ); // Expect exception with message Assert.WillRaiseWithMessage( procedure begin raise EArgumentException.Create('Invalid argument'); end, EArgumentException, 'Invalid argument' ); // Expect descendant exception Assert.WillRaiseDescendant( procedure begin raise EArgumentOutOfRangeException.Create('Out of range'); end, EArgumentException // EArgumentOutOfRangeException descends from this ); // Expect any exception Assert.WillRaiseAny( procedure begin raise Exception.Create('Something went wrong'); end ); // Expect no exception Assert.WillNotRaise( procedure begin // Safe operation Writeln('This is fine'); end, Exception ); end; ``` -------------------------------- ### DUnitX Assert: Null and Empty Checks Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Illustrates DUnitX Assert methods for verifying if objects are nil, strings are empty, or collections contain no items. Includes checks for both null/empty and not-null/not-empty conditions. ```Pascal procedure TAssertExamples.TestNullAndEmptyAssertions; var Obj: TObject; Str: string; List: TStringList; begin Obj := nil; Assert.IsNull(Obj, 'Object should be nil'); Obj := TObject.Create; try Assert.IsNotNull(Obj, 'Object should not be nil'); finally Obj.Free; end; // Empty checks Str := ''; Assert.IsEmpty(Str, 'String should be empty'); Str := 'content'; Assert.IsNotEmpty(Str, 'String should have content'); List := TStringList.Create; try Assert.IsEmpty(List, 'List should be empty'); List.Add('item'); Assert.IsNotEmpty(List, 'List should have items'); finally List.Free; end; end; ``` -------------------------------- ### SetupFixture Attribute for Test Fixture Initialization (Delphi) Source: https://github.com/vsofttechnologies/dunitx/wiki/SetupFixture The SetupFixture attribute in DUnitX marks a procedure to be executed once before all tests in a test fixture. This is useful for setting up common test data or environment configurations. Ensure only one method is decorated with SetupFixture to avoid unpredictable behavior. ```delphi [TestFixture] TMyTestFixture = class [SetupFixture] procedure SetupFixture; [Test] procedure Test_That_Something_Works; ... end; ``` -------------------------------- ### Implementing a Test Data Provider Base Class in DUnitX (Pascal) Source: https://github.com/vsofttechnologies/dunitx/blob/master/TestCaseProvider.md Illustrates the basic structure of a test data provider class in DUnitX, which must inherit from TTestDataProviderBase. It outlines the essential methods to implement: constructor, destructor, GetCaseAmount, GetCaseName, and GetCaseParams, each serving a specific role in generating test cases. ```pascal type TMyProviderClass = class(TTestDataProviderBase) protected function GetCaseAmount(const ATestName: string): Integer; function GetCaseName(const ATestName: string; ACaseIndex: Integer): string; function GetCaseParams(const ATestName: string; ACaseIndex: Integer): TArray; public constructor Create; destructor Destroy; end; ``` -------------------------------- ### Implement Dynamic Test Data Provider in Pascal Source: https://context7.com/vsofttechnologies/dunitx/llms.txt This Pascal code defines a custom test data provider by inheriting from TTestDataProvider. It implements methods to supply test case counts, names, and parameters dynamically, demonstrating data generation and retrieval for test methods. ```pascal unit DataDrivenTests; interface uses System.Generics.Collections, DUnitX.Types, DUnitX.InternalDataProvider, DUnitX.TestDataProvider, DUnitX.TestFramework; type TTestRecord = record Input1, Input2: Integer; ExpectedSum: Integer; ExpectedEqual: Boolean; end; TMyDataProvider = class(TTestDataProvider) private FTestData: TList; public constructor Create; override; destructor Destroy; override; function GetCaseCount(const MethodName: string): Integer; override; function GetCaseName(const MethodName: string; const CaseNumber: Integer): string; override; function GetCaseParams(const MethodName: string; const CaseNumber: Integer): TValueArray; override; end; [TestFixture] TDataDrivenTests = class public [Test] [TestCaseProvider(TMyDataProvider)] procedure TestAddition(A, B, Expected: Integer); [Test] [TestCaseProvider(TMyDataProvider)] procedure TestEquality(A, B: Integer; Expected: Boolean); end; implementation constructor TMyDataProvider.Create; var Item: TTestRecord; I: Integer; begin inherited; FTestData := TList.Create; // Generate test data (could load from file/database) for I := 1 to 10 do begin Item.Input1 := I; Item.Input2 := I * 2; Item.ExpectedSum := I + I * 2; Item.ExpectedEqual := False; FTestData.Add(Item); end; // Add equality case Item.Input1 := 5; Item.Input2 := 5; Item.ExpectedSum := 10; Item.ExpectedEqual := True; FTestData.Add(Item); end; destructor TMyDataProvider.Destroy; begin FTestData.Free; inherited; end; function TMyDataProvider.GetCaseCount(const MethodName: string): Integer; begin Result := FTestData.Count; end; function TMyDataProvider.GetCaseName(const MethodName: string; const CaseNumber: Integer): string; begin if MethodName = 'TestAddition' then Result := Format('Add_%d_%d', [FTestData[CaseNumber].Input1, FTestData[CaseNumber].Input2]) else Result := Format('Equal_%d_%d', [FTestData[CaseNumber].Input1, FTestData[CaseNumber].Input2]); end; function TMyDataProvider.GetCaseParams(const MethodName: string; const CaseNumber: Integer): TValueArray; begin SetLength(Result, 3); Result[0] := FTestData[CaseNumber].Input1; Result[1] := FTestData[CaseNumber].Input2; if MethodName = 'TestAddition' then Result[2] := FTestData[CaseNumber].ExpectedSum else Result[2] := FTestData[CaseNumber].ExpectedEqual; end; procedure TDataDrivenTests.TestAddition(A, B, Expected: Integer); begin Assert.AreEqual(Expected, A + B); end; procedure TDataDrivenTests.TestEquality(A, B: Integer; Expected: Boolean); begin Assert.AreEqual(Expected, A = B); end; initialization TestDataProviderManager.RegisterProvider('MyProvider', TMyDataProvider); TDUnitX.RegisterTestFixture(TDataDrivenTests); end. ``` -------------------------------- ### Registering a Test Data Provider in DUnitX (Pascal) Source: https://github.com/vsofttechnologies/dunitx/blob/master/TestCaseProvider.md Demonstrates how to register a custom test data provider class with the TestDataProviderManager. This involves calling the RegisterProvider method within the initialization section of the provider class, associating a unique name with the provider class itself. ```pascal initialization TestDataProviderManager.RegisterProvider('MyProviderName', TMyProviderClass); end. ``` -------------------------------- ### DUnitX Assert: Collection Membership Checks Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Shows how to use DUnitX Assert methods to check if a collection contains a specific element or does not contain a specific element. Supports generic collections. ```Pascal procedure TAssertExamples.TestCollectionAssertions; var Numbers: TArray; begin Numbers := [1, 2, 3, 4, 5]; Assert.Contains(Numbers, 3, 'Should contain 3'); Assert.DoesNotContain(Numbers, 10, 'Should not contain 10'); end; ``` -------------------------------- ### Control Test Execution with DUnitX Attributes in Delphi Source: https://context7.com/vsofttechnologies/dunitx/llms.txt Illustrates various attributes in Delphi's DUnitX framework to control how individual test methods are executed. This includes enabling/disabling tests, categorizing them for filtering, ignoring tests with reasons, enforcing maximum execution times, repeating tests, and specifying expected exceptions. These attributes provide fine-grained control over the testing process. ```delphi type [TestFixture] TMyTests = class public [Test] procedure BasicTest; [Test(False)] // Disabled test - won't run procedure DisabledTest; [Test] [Category('Slow')] // Categorize for filtering procedure SlowTest; [Test] [Ignore('Waiting for bug fix in issue #123')] procedure IgnoredTest; [Test] [MaxTime(1000)] // Fail if test takes longer than 1000ms procedure TimedTest; [Test] [RepeatTest(5)] // Run this test 5 times procedure RepeatedTest; [Test] [WillRaise(EDivByZero)] // Test expects this exception procedure TestDivisionByZero; [Test] [IgnoreMemoryLeaks] // Don't report memory leaks for this test procedure TestWithKnownLeak; end; implementation procedure TMyTests.BasicTest; begin Assert.IsTrue(True, 'This test passes'); end; procedure TMyTests.TestDivisionByZero; var x, y: Integer; begin x := 10; y := 0; x := x div y; // Will raise EDivByZero - test passes end; procedure TMyTests.TimedTest; begin // Must complete within 1000ms or test fails PerformQuickOperation; Assert.Pass; end; initialization TDUnitX.RegisterTestFixture(TMyTests); end. ``` -------------------------------- ### Using TestCaseProvider Attribute in DUnitX Tests (Pascal) Source: https://github.com/vsofttechnologies/dunitx/blob/master/TestCaseProvider.md Shows how to apply the TestCaseProvider attribute to a test method in DUnitX. The attribute takes the registered provider name as a parameter, signaling the framework to use this provider to generate test cases for the decorated method. ```pascal [TestCaseProvider('MyProviderName')] procedure MyDynamicTest(Param1: Integer; Param2: string); begin // Test logic using Param1 and Param2 end; ``` -------------------------------- ### Bash Post-Commit Hook for DUnitX File Management Source: https://github.com/vsofttechnologies/dunitx/blob/master/post-commit.txt This bash script is intended to be used as a post-commit hook. It checks for the existence of 'VSoft.DUnitX.dspec', deletes it if found, and then force-checks it out from the repository's HEAD. This ensures the file always contains the latest commit hash. It includes error handling and colored output for clarity. ```bash #!/bin/bash # Post commit hook to force dspec to always have current commit hash TARGET_FILE="VSoft.DUnitX.dspec" # Color codes for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}Post-commit hook: Processing ${TARGET_FILE}${NC}" # Check if the target file exists if [ -f "$TARGET_FILE" ]; then echo -e "${RED}Deleting ${TARGET_FILE}${NC}" rm "$TARGET_FILE" # Verify deletion if [ ! -f "$TARGET_FILE" ]; then echo -e "${GREEN}File successfully deleted${NC}" else echo -e "${RED}Error: Failed to delete ${TARGET_FILE}${NC}" exit 1 fi else echo -e "${YELLOW}File ${TARGET_FILE} does not exist, skipping deletion${NC}" fi # Force checkout the file from the repository echo -e "${YELLOW}Force checking out ${TARGET_FILE} from HEAD${NC}" # Use git checkout to restore the file from the latest commit git checkout HEAD -- "$TARGET_FILE" # Check if the checkout was successful if [ $? -eq 0 ]; then if [ -f "$TARGET_FILE" ]; then echo -e "${GREEN}Successfully restored ${TARGET_FILE} from repository${NC}" else echo -e "${YELLOW}File ${TARGET_FILE} was not restored (may not exist in repository)${NC}" fi else echo -e "${RED}Error: Failed to checkout ${TARGET_FILE}${NC}" exit 1 fi echo -e "${GREEN}Post-commit hook completed successfully${NC}" ``` -------------------------------- ### Log Messages Within DUnitX Tests (Pascal) Source: https://context7.com/vsofttechnologies/dunitx/llms.txt This Pascal code demonstrates how to emit log messages from within DUnitX tests. It shows usage of `TDUnitX.CurrentRunner.Log` with different log levels and direct output via `WriteLn`. These logs are visible in the test runner's output, aiding in debugging. ```pascal type [TestFixture] TLoggingExample = class public [Test] procedure TestWithLogging; end; implementation procedure TLoggingExample.TestWithLogging; begin // Using TDUnitX.CurrentRunner TDUnitX.CurrentRunner.Log(TLogLevel.Information, 'Starting test operation'); TDUnitX.CurrentRunner.Log(TLogLevel.Warning, 'This is a warning message'); TDUnitX.CurrentRunner.Log(TLogLevel.Error, 'This is an error message'); // Simple log (defaults to Information level) TDUnitX.CurrentRunner.Log('Processing item...'); // DUnit compatibility - Status method TDUnitX.CurrentRunner.Status('Status update: 50% complete'); // WriteLn redirects to log Self.WriteLn('Output via WriteLn'); Assert.Pass('Test completed with logging'); end; initialization TDUnitX.RegisterTestFixture(TLoggingExample); end. ``` -------------------------------- ### TestFixture with Ignore Attribute Source: https://github.com/vsofttechnologies/dunitx/wiki/TestFixture Illustrates the use of the TestFixture and Ignore attributes to mark a test fixture and all its tests for exclusion from test runs. This is useful for temporarily disabling tests. ```delphi [TestFixture('ExampleFixture2')] [Ignore] TMyExample2Tests = class public [Test] procedure ATest; ... ``` -------------------------------- ### DUnitX TestCase Attribute Usage Source: https://github.com/vsofttechnologies/dunitx/wiki/TestCase Demonstrates how to use the TestCase attribute to pass multiple sets of string values to a test method. The attribute supports specifying a custom separator for the values. Values are coerced to the expected parameter types. ```delphi [Test] [TestCase('Case 1','1,2')] [TestCase('Case 2','3,4')] [TestCase('Case 3','5;6', ';')] procedure RunMeMoreThanOnce(param1 : integer; param2 : integer); ``` -------------------------------- ### DUnitX TearDown Method Execution in Test Fixture Source: https://github.com/vsofttechnologies/dunitx/wiki/Teardown Demonstrates the usage of the TearDown attribute within a DUnitX test fixture. The method decorated with [TearDown] is automatically executed after each [Test] method in the TTestSomething class. ```delphi [TestFixture] TTestSomething = class [TearDown] procedure TestTearDown; [Test] procedure Test_That_Something_Works; ... end; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.