Hopefully this question has an easy answer. It’s probably something stupid I’m doing!
In Eclipse, Run As Python Unit-Test for the following code:
import unittest
from ShipClass import *
from Graphics import *
class UnitTesting(unittest.TestCase):
def testInit(self):
self.screen = load_screen()
assert load_background() == True
print("Here!")
def spawnShip(self):
ship = Ship((self.screen.get_rect().x, self.screen.get_rect().y))
self.screen.blit(ship.image, ship.rect)
print("Here!")
assert updateDisplay() == True
The code outputs only one “Here!” to the console. It also says, “Ran 1 test…”, etc.
Why isn’t it running both tests?
Thanks for your help.
The Python unittest runner uses method name prefixes to find tests.
spawnShipis not recognised as a test method. To fix that, call it something liketestSpawnShip