-1

Is it OK to verify business rule components in form of unit tests, or should unit tests only verify the design and low-level structures?

Given we have a class that implements a specific business rule, or an entity in terms of DDD, that contain it's own business logic.

We can create unit tests which can verify the structure of these classes and also create some unit tests with test data for verifying the business rules implementation.

Are second set of tests for verifying business rules implementation OK to be in unit-test form?

2
  • You are talking about business rules, I assume your software product has been integrated. I am not sure about the "unit tests", which forms do you come in as?
    – Yu Zhang
    Jan 11, 2017 at 7:30
  • @YuZhang - Given we have a class that implements a specific business rule, or an entity in terms of DDD, that contain it's own business logic. We can create unit tests which can verify the structure of these classes and also create some unit tests with test data for verifying the business rules implementation. Jan 11, 2017 at 7:43

1 Answer 1

0

It doesn't matter what tool you use to perform a type of test as long as that tool does the job well enough.

Unit tests by definition test a single code unit in isolation.

If you have a class with some properties and business rules expressed as methods on that class, you can unit test both properties and methods.

Testing the implementation of those rules in the application means testing that the inputs from a different layer are correctly passed to the class, and the outputs of business rule interpretation are correctly returned to the other layer. In short, testing the implementation is an integration test.

The technique or framework you use to create and run integration tests can be the same as the technique or framework you use to create and run unit tests.

Your question is using technique or framework to mean type of test. I think this is why you are having problems.

Type of Test - Usually Tested by (framework or person)

Unit test - Unit testing framework with mocks/stubs/shims as placeholders for dependent objects

Integration Test - Unit testing framework instantiating actual dependent objects, BDD Testing Framework (the Given-When-Then frameworks)

Functional Test - GUI testing framework, BDD testing framework, manual tester.

The type of test being performed does not depend on the tool you use to test it. If the best way to test integration of a business object is to use a unit testing tool, use the unit testing tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.