Teste Unitário
Testando
PloneTestCase faz isto facilmente
Economiza um pouco de tempo para muito de preocupação
Pensar amplamente sobre os benefícios
Por exemplo, os bons testes permitirão reusar mais seu código, porque você terá a confiança para fazer assim.
Olhar um produto com boa evidência de testes &mdash tal como ATContentTypes
Mechanize-driven para testes de elementos da interface
Considerar faturar separadamente isto para seus clientes
Modelo para a instalação de teste
Modelo para a instalação de teste para PloneHelpCenter:
class PHCSiteTestCase(ArchetypesTestCase.ArcheSiteTestCase):
"""Test structure for PHC"""
def afterSetUp(self):
ArchetypesTestCase.ArcheSiteTestCase.afterSetUp(self)
self._portal = self.app.portal
# login as manager
user = self.getManagerUser()
newSecurityManager(None, user)
self._portal.invokeFactory(type_name='HelpCenter',
id='helpctr')
self._hc=getattr(self._portal, 'helpctr')
def beforeTearDown(self):
ArchetypesTestCase.ArcheSiteTestCase.beforeTearDown(self)
noSecurityManager()
del self._hc
Modelo de Teste
Modelo de teste para o PloneHelpCenter
class TestFAQ(PHCTestCase):
"""Test those parts of FAQ and FAQ Folder that don't
require a real site framework. Allows tests to run faster
"""
def afterSetUp(self):
PHCTestCase.afterSetUp(self)
self._dummy = FAQ.HelpCenterFAQ(oid='dummy')
self._dummy.initializeArchetype()
def test_answerSTX(self):
dummy = self._dummy
dummy.setAnswer(example_stx, mimetype='text/structured')
answer=no_whitespace.sub('',dummy.getAnswer())
self.failUnless(answer==example_html, 'Value is %s' % answer)
Mais informações sobre teste unitário
Lotes material e dos tutoriais disponíveis na WEB
Pegue a apresentação "Unit Testing Zope for Fun and Profit" de Stefan Holek para a EuroPython
Um livro muito bom é Unit Testing book de Kent Beck