lundi 3 août 2020

C# Testing Framework Loop Through Test Cases

I am looking to use MS testing framework to test a tax calculator and needs to run over 100 test cases. As see below, I have set up an array of testCases and loop through each but the when I run Tests, it only returns one return.

Question:

  1. Is there a way for every test display result?
  2. How do I return each test results? Currently, the system only returns values if failed.
            [DataTestMethod]
            public void CalculateResult(int val)
            {

                // arrange
                int[] testCase = { 1000,2000, 35000, 400003, 59509 };

                foreach (int income in testCase)
                {

                    double expectOutput = TaxCalculator(income);

                    // act
                    
                    SUT.GeneralTaxRule generalTaxationRule = new SUT.GeneralTaxRule(income);
                    
                    double actualOutput = generalTaxationRule.getTax();

                    // assert
                    Assert.AreEqual(expectOutput, actualOutput);
                    Console.WriteLine(expectOutput, actualOutput);
                }

            }

Aucun commentaire:

Enregistrer un commentaire