I'm exploring DUnitX for the first time and rebuilding a Windows 10 calculator clone to practice test-driven development. I have three test classes (paralleling a main CalculatorLogic class, an Equation class, and an Operand class). I've written four tests for Operand that simply assert that a value (float) or operator (enum) set in the Operand object is the same received from the 'get' method. Set/Get validation.
unit OperandTest;
interface
uses
DUnitX.TestFramework, Vcl.Dialogs, Operands, Operation, System.Rtti;
type
[TestFixture]
OperandTester = class
private
op : Operand;
public
[Setup]
procedure Setup;
[TearDown]
procedure TearDown;
[Test]
[TestCase('0','0')]
[TestCase('0.0','0.0')]
[TestCase('-0.1','-0.1')]
[TestCase('maxInt','MaxInt')]
[TestCase('maxLongInt','MaxLongInt')]
[TestCase('0.00000000001','0.00000000001')]
procedure TestGetValueSet(const setValue : Real);
[Test]
[TestCase('0/1','0,1')]
[TestCase('-0.1/0.1','-0.1,0.1')]
[TestCase('99999999999/0','99999999999,0')]
[TestCase('0.00000000001/0.1','0.00000000001,0.1')]
procedure TestNotGetValueNotSet(const setValue, falseValue : Real);
[Test]
[TestCase('Add','OpType.Add')]
[TestCase('Nothing','OpType.Nothing')]
procedure TestGetOpSet(const setOp : OpType);
[Test]
[TestCase('Add/Nothing','OpType.Add,OpType.Nothing')]
[TestCase('Nothing/Multiply','OpType.Nothing,OpType.Multiply')]
[TestCase('Nothing/Nothing','OpType.Nothing,OpType.Nothing')]
procedure TestNotGetOpNotSet(const setOp, falseOp : OpType);
end;
The issue I'm facing is that the 10 tests for value (first two functions) run but the second two for operator do not. The following DUnitX report shows 14 tests, 10 for the OperandTest value tests and 4 dummy tests for the other test units. No indication of TestGetOpSet
or TestNotGetOpNotSet
in the report, no indication that they were ignored, and a ShowMessage in those procedures is not executed.
**********************************************************************
* DUnitX - (c) 2015-2018 Vincent Parrett & Contributors *
* *
* License - http://www.apache.org/licenses/LICENSE-2.0 *
**********************************************************************
Fixture : EquationTest
-------------------------------------------------
Fixture : EquationTest.EquationTester
-------------------------------------------------
Test : EquationTest.EquationTester.Test1
-------------------------------------------------
Running Setup for : Test1
Executing Test : Test1
Running Teardown for Test : Test1
Success.
Test : EquationTest.EquationTester.Test2
-------------------------------------------------
Running Setup for : Test2
Executing Test : Test2
Running Teardown for Test : Test2
Success.
Running Fixture Teardown Method : Destroy
Fixture : CalcTest
-------------------------------------------------
Fixture : CalcTest.VCLCalcTester
-------------------------------------------------
Test : CalcTest.VCLCalcTester.Test1
-------------------------------------------------
Running Setup for : Test1
Executing Test : Test1
Running Teardown for Test : Test1
Success.
Test : CalcTest.VCLCalcTester.Test2
-------------------------------------------------
Running Setup for : Test2
Executing Test : Test2
Running Teardown for Test : Test2
Success.
Running Fixture Teardown Method : Destroy
Fixture : OperandTest
-------------------------------------------------
Fixture : OperandTest.OperandTester
-------------------------------------------------
Test : OperandTest.OperandTester.TestGetValueSet.0
-------------------------------------------------
Running Setup for : TestGetValueSet.0
Executing Test : TestGetValueSet.0
Running Teardown for Test : TestGetValueSet.0
Success.
Test : OperandTest.OperandTester.TestGetValueSet.0.0
-------------------------------------------------
Running Setup for : TestGetValueSet.0.0
Executing Test : TestGetValueSet.0.0
Running Teardown for Test : TestGetValueSet.0.0
Success.
Test : OperandTest.OperandTester.TestGetValueSet.-0.1
-------------------------------------------------
Running Setup for : TestGetValueSet.-0.1
Executing Test : TestGetValueSet.-0.1
Running Teardown for Test : TestGetValueSet.-0.1
Success.
Test : OperandTest.OperandTester.TestGetValueSet.maxInt
-------------------------------------------------
Running Setup for : TestGetValueSet.maxInt
Executing Test : TestGetValueSet.maxInt
Running Teardown for Test : TestGetValueSet.maxInt
Success.
Test : OperandTest.OperandTester.TestGetValueSet.maxLongInt
-------------------------------------------------
Running Setup for : TestGetValueSet.maxLongInt
Executing Test : TestGetValueSet.maxLongInt
Running Teardown for Test : TestGetValueSet.maxLongInt
Success.
Test : OperandTest.OperandTester.TestGetValueSet.0.00000000001
-------------------------------------------------
Running Setup for : TestGetValueSet.0.00000000001
Executing Test : TestGetValueSet.0.00000000001
Running Teardown for Test : TestGetValueSet.0.00000000001
Success.
Test : OperandTest.OperandTester.TestNotGetValueNotSet.0/1
-------------------------------------------------
Running Setup for : TestNotGetValueNotSet.0/1
Executing Test : TestNotGetValueNotSet.0/1
Running Teardown for Test : TestNotGetValueNotSet.0/1
Success.
Test : OperandTest.OperandTester.TestNotGetValueNotSet.-0.1/0.1
-------------------------------------------------
Running Setup for : TestNotGetValueNotSet.-0.1/0.1
Executing Test : TestNotGetValueNotSet.-0.1/0.1
Running Teardown for Test : TestNotGetValueNotSet.-0.1/0.1
Success.
Test : OperandTest.OperandTester.TestNotGetValueNotSet.99999999999/0
-------------------------------------------------
Running Setup for : TestNotGetValueNotSet.99999999999/0
Executing Test : TestNotGetValueNotSet.99999999999/0
Running Teardown for Test : TestNotGetValueNotSet.99999999999/0
Success.
Test : OperandTest.OperandTester.TestNotGetValueNotSet.0.00000000001/0.1
-------------------------------------------------
Running Setup for : TestNotGetValueNotSet.0.00000000001/0.1
Executing Test : TestNotGetValueNotSet.0.00000000001/0.1
Running Teardown for Test : TestNotGetValueNotSet.0.00000000001/0.1
Success.
Running Fixture Teardown Method : Destroy
Done testing.
Tests Found : 14
Tests Ignored : 0
Tests Passed : 14
Tests Leaked : 0
Tests Failed : 0
Tests Errored : 0
Done.. press <Enter> key to quit.
I'm having a hard time finding sample code or tutorials with more than two test procedures so I don't know if there's any additional notation I need to add to successive tests. What am I missing? What formatting or DUnitX notation is incorrect/missing that would make the test suite completely ignore the last two tests? Thanks!
Procedure implementation, if it helps:
procedure OperandTester.TestGetValueSet(const setValue : Real);
begin
op.setValue(setValue);
Assert.AreEqual(op.getValue(), setValue);
end;
procedure OperandTester.TestNotGetValueNotSet(const setValue, falseValue : Real);
begin
op.setValue(setValue);
Assert.AreNotEqual(op.getValue(), falseValue);
end;
procedure OperandTester.TestGetOpSet(const setOp : OpType);
begin
ShowMessage ('TestGetOpSet');
op.setOperation(setOp);
Assert.AreEqual(op.getOperation(), setOp);
end;
procedure OperandTester.TestNotGetOpNotSet(const setOp, falseOp : OpType);
begin
op.setOperation(setOp);
Assert.IsFalse(Ord(op.getOperation())= Ord(falseOp));
end;