In which cases should I combine several test cases inside one test suite?
Let me give you some examples.
Example 1
I have utils.py
file that contains several non-related general-purpose functions like dict_join
and split_first_n
. Should I create one test case for both of them and define two methods that checks each of these functions? Also should I create separate functions to test each set of parameters (e.g. expected and unexpected ones -- None
, -1 etc).
class TestUtils(unittest.TestCase):
def test_dict_join(self):
pass
def test_split_first_n(self):
pass
Example 2
I have TCPSocket
wrapper around the Socket
object from the Python's standard library with functions like recv_bytes
and recv_until
. Should I create one test case for this class with the methods for each of its functions that I want to test?
class TestTCPSocket(unittest.TestCase):
def setUp(self):
self.sock = TCPSocket()
self.sock.connect('127.0.0.1', 12345)
def test_recv_bytes(self):
pass
def test_recv_until(self):
pass
Am I right?
Aucun commentaire:
Enregistrer un commentaire