Monday, 20 May 2013

Should an integration test be used in place of a unit test involving personal data?

Should an integration test be used in place of a unit test involving personal data?

I am trying to develop a series of unit tests for a production system that are dependent on a person's social security number. While I am more than comfortable hard coding a clearly bad social security number to test for failure, I'm uneasy about including one that is good for proper (and passing) results. The following is a simplified test that I'm using:
[TestMethod]
    public void API_Hours_Get()
    {
        var controller = new HoursController();
        var employee = new EmployeeController();
        var badResult = controller.Get(123124569);
        var goodResult = controller.Get(employee.GetEmployeeByUserId("Username").First().SSNumber);
        Assert.IsFalse(badResult.Any());
        Assert.IsTrue(goodResult.Any());
    }
This test passes just fine and gives me the results I want. But, from my understanding, it is an integration test. From a best practices perspective, is this substitute okay for my test suite and just ignore the fact that I don't have a 'pure' unit test for the SSN-dependent modules or is there a better approach for situations like this?

No comments:

Post a Comment