VSoftTechnologies / DUnitX

Delphi Unit Test Framework
Apache License 2.0
383 stars 200 forks source link

CustomTestCaseSourceAttribute - Allows creation of test case where param list count does not match test method. #68

Closed staticcat closed 10 years ago

staticcat commented 10 years ago

If you create the following class.

MockTestSourceAttribute = class(CustomTestCaseSourceAttribute)
protected
    function GetCaseInfoArray : TestCaseInfoArray; override;
end;

function MockTestSourceAttribute.GetCaseInfoArray: TestCaseInfoArray;
begin
   SetLength(result,3);
   result[0] := TValue.From(0); 
   result[1] := TValue.From(1); 
   result[2] := TValue.From(2); 
end;

You are able to still call this on a test method with fewer parameters.

    [Test]
    [MockTestSource]
    procedure DataTest(Value : Integer; Value2 : Integer);

The test should fail as the parameters do not match up. Currently you can get access violations on some runs. Its very inconsistent.

vincentparrett commented 10 years ago

Test Cases definately need some love.. and we need to find a more type safe way of executing them. Open to suggestions.

staticcat commented 10 years ago

This is more of a public note. The number of parameters is available on the method RTTI. I am looking at validating against this. Working on a pull request now. Will update this issue when I have one.

vincentparrett commented 10 years ago

Might want to wait for my merge.. quite a few changes.

staticcat commented 10 years ago

Will do.

staticcat commented 10 years ago

The test I was looking at performing is already done in the test create. There must be something else occurring with type conversion, etc. Investigating.

staticcat commented 10 years ago

Turns out this was an overflow issue in my testing with arrays. Not an issue.