Melhorando o feedback de seus testes

pernalonga

Em Maio de 2015 publiquei um video da série “Aprendendo Protractor”, no qual expliquei como executar somente um teste de uma suite de testes, ou como pular um teste em específico.

O tempo passou e tenho uma nova dica a respeito do assunto. Quando você resolve pular um teste, você precisa mudar a função it pela função xit, porém, ao executar um teste desta forma, algo como o seguinte é exibido como resultado, quando utilizando a versão mais atual do Protractor:

Pending:
1) Video Artifact - verify presence of the annotation list in a video artifact.
  No reason given

2) Annotation - should be available for Researcher user to create it.
  No reason given

Ou seja, caso você não explique ao Protractor o motivo pelo qual tais testes estão sendo pulados, não há feedback quando os mesmos são executados (no reason given).

Porém, facilmente você pode fornecer ao Protractor uma explicação sobre o motivo de um determinado teste estar sendo pulado, e ele não fica esquecido =). Para isto, basta chamar a função pend a partir da função xit. Veja os exemplos abaixo:

xit(‘verify presence of the annotation list in a video artifact.', function () {
  ArtifactVideoPage.add('Video Artifact', 'videoFile.mp4');
  expect(ArtifactVideoPage.annotationList.isPresent).toBe(true);
}).pend('This test is still not ready. An annotation needs to be created for the video artifact.’);

xit('should be available for Researcher user to create it.', function() {
  AuthenticationPage.login(browser.params.defaultUser.username, browser.params.defaultUser.pass);
  SamplePage.get('content/annotation');
  // @TODO: Implement the add method in the annotation page object.
  AnnotationPage.add();
  expect(SamplePage.messageBox.getText()).toContain('Anotação criada com sucesso!');
}).pend('This test will be skipped because the add method from the annotation page is not ready yet.’);

Ao adicionar a função pend, o seguinte resultado é exibido após a execução dos testes:

Pending:
1) Video Artifact - verify presence of the annotation list in a video artifact.
  This test is still not ready. An annotation needs to be created for the artifact.

2) Annotation - should be available for Researcher user to create it.
  This test will be skipped because the add method from the annotation page is not ready yet.

E por hoje é só pessoal…

porhojeehsoh

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s