I copy the script from here (see below) and click on “Run Script” button but the Blender is crashed.
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foof'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)
if __name__ == '__main__':
unittest.main()
I found the solution for my problem here. It runs from Blender by click on “Run Script” button
import unittest
class BlenderProjectTest(unittest.TestCase):
def testDBConnection(self):
print('I am in a test case')
self.assert_(1)
#if __name__ == '__main__':
try:
try:
print('I am __main__ and I am about to run unittest.main()')
unittest.main()
except SystemExit:
pass
except:
raise
except:
print('Exception: ')
Blender python is embedded inside the blender executable.
Also you do not need to use the python’s implementation of TDD you can create your own depending on your needs. In the end TDD is all about automated testes. Unintest offer some convenience object that will make your life easier but is not made with blender python in mind. For example unittest is made to work from the terminal but we blender python coders work mainly from inside the Blender GUI.
You can do some cool things with a bit of imagination you can for example create a collection of tests that run as a separate addon.