1

I am writing test cases for a python code that mainly parses and interprets user input and calls business layer functions to do database interactions (inserts and selects). How can I write/plan unit test cases for it.

Does calling a dummy version of the business logic functions make sense?

softwarematter
  • 28,015
  • 64
  • 169
  • 263

2 Answers2

1

Yes testing you "business logic" is practical. Unit Testing for Database interaction is not. Suggest http://pyunit.sourceforge.net/

Dane Balia
  • 5,271
  • 5
  • 32
  • 57
1

If you use dummy business logic, what do you end up testing then? Your business logic is really what you should be unit testing.

You should using mocking to simulate user input and avoid database interactions. Have a look at my answer to How to mock an HTTP request in a unit testing scenario in Python.

Community
  • 1
  • 1
Rodrigue
  • 3,617
  • 2
  • 37
  • 49