I have read the python documentation for unittest and found it a bit confusing. I have written a test file with methods for testing various classes and methods, along the lines of:
class test_class_Graph(unittest.TestCase):
def __init__(self):
test_graph = Graph()
def test_method__init__(self):
assertEquals(x, y)
def test_method_node(self, name):
node = test_graph.node(name)
assertIsInstance(node, Node)
assertEquals(node.name, name)
class test_class_Node(unittest.TestCase):
etc
I have created some test-methods with 'if-else' statements, corresponding to 'if-else' statements in the actual methods. These are a kind of test-case - under certain conditions, the method should act one way, under other conditions, we expect the method to produce something different.
There are certain cases where I don't want to partition the set of possible conditions into 'if-else' statements, I just want to test a few 'samples' for more complicated methods. For example, if the input is a specific 'X', I want the output to be a specific 'Y'.
Where do I write specific test cases like this? Am I supposed to run my tests from the command line, entering inputs there? Or am I supposed to simply execute a test file from the command line with 'run', and somehow have a sequence of pre-selected inputs and expected outputs?
Aucun commentaire:
Enregistrer un commentaire