-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTestWithVersion1.py
More file actions
62 lines (52 loc) · 2.36 KB
/
UnitTestWithVersion1.py
File metadata and controls
62 lines (52 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Purpose:
Use Python Unit Test testcases composed by DeclareATest.
Date: 13OCT2016
Author: DJS
"""
import DeclareATest
from .core.TestSubject import TestSubject
import unittest
class VersionOneUnitTests(unittest.TestCase):
def commonArrange():
TestSubject(False)
def test_SetFlagTrue(self):
test = DeclareATest().ArrangedBy(self.commonArrange)\
.ThatExpects(lambda s: s.GetFlag() is True,"Subject Falg is false.")\
.When(lambda c: c[TestComponents.Subject].SetFlagTrue())
test.Run()
def test_SetFlagFalse(self):
test = DeclareATest().ArrangedBy(self.commonArrange)\
.ThatExpects(lambda s: s.GetFlag is False,"Subject flag is true")\
.When(lambda c: c[TestComponents.Subject].SetFlagFalse())
test.Run()
def test_SetNameToJohn(self):
test = DeclareATest().ArrangedBy(self.commonArrange)\
.ThatExpects(lambda s: s.GetName() == 'John',"Subject Name was not john")\
.When(lambda c: c[TestComponents.Subject].SetName('John'))
test.Run()
def test_MultiPass(self): #*wink* hehe multi-pass
def action(context):
context[TestComponents.Subject].SetFlagTrue()
context[TestComponents.Subject].SetName('John')
test = DeclareAtest().ArrangedBy(self.commonArrange)\
.ThatExpects(lambda s: s.GetFlag() is True,"Subject flag was not true")\
.ThatExpects(lambda s: s.GetName() == 'John',"Subject name was not john")\
.When(action)
test.Run()
@unittest.expectedFailure
def test_MultiFail(self):
test = DeclareATest().ArrangedBy(self.commonArrange)\
.ThatExpects(lambda s: s.GetFlag() is True,"Subject flag was not true")\
.ThatExpects(lambda s: s.GetName() == 'John',"Subject name was not john")\
.When(lambda c: """Do Nothing""" )
test.Run()
@unittest.expectedFailure
def test_Mixed(self):
test = DeclareATest().ArrangedBy(self.commonArrange)\
.ThatExpects(lambda s: s.GetFlag() is True,"Subject flag awas not true")\
.ThatExpects(lambda s: s.GetName() == 'John',"Subject name was not john")\
.When(lambda c: c[TestComponents.Subject].SetFlagTrue())
test.Run()
if _name_ == '_main_':
unittest.main()