Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Protractor Tests - should E2E tests have fixtures?

There are ton of questions asking how to mock http responses in protractor tests. How to do this is not the question, should we do this is the question.

http://en.wikipedia.org/wiki/Test_fixture#Software

I've been a QA Engineer for over 4 years, and most of my automated test experience deals with both low level (unit) tests of controllers, models, etc and high level (integration) tests of full systems. In my ruby world experience, we used Capybara for integration tests along with blueprint and factorygirl (for different projects) to create mock database entries. This was our integration/E2E testing.

I've only recently moved to a javascript team using AngularJS. The original built-in testing framework (now deprecated) had a mock Backend module which seemed suitable for our needs. Protractor is now the standard. Only after protractor gained steamed, have I heard the backlash of using fixtures for E2E testing. Many posts are pointing out that E2E testing should be testing the full stack, so any backends should not be mocked and be accessible.

Should integration tests use fixtures, and why?

like image 741
jonh Avatar asked Dec 23 '13 19:12

jonh


People also ask

Why Protractor is deprecated?

The development team behind Protractor decided that more modern testing software can better serve their users. This is mainly because, in order for Protractor to update to its fullest potential, users would have to rewrite all their tests.

What is E2E testing Protractor?

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, using Selenium. We can say in other words that Protractor is a tool that helps us to test Angular Apps using Selenium.

Is Cypress better than Protractor?

Cypress is an automated testing framework designed specifically for the modern Web. Cypress is based on the new architecture and runs in the same execution cycle as the application under test. As a result, Cypress has conducted better, faster and more reliable tests on all products.


1 Answers

There is a vocabulary problem here. What is called "e2e" testing in the Angular world has nothing to do with end-to-end testing. It is an end-to-end of the UI part only, which means no e2e test at all. It is UI testing.

Gojko Adzic, in "spec by example" book, recommands to do functional, fixture-based testing "below the skin of the application", i.e. without the UI part.

To answer your question :

-Should UI tests have fixture? No, use mocks or stubs

-Should Backend tests have fixture ? Yes

like image 90
bdavidxyz Avatar answered Oct 01 '22 06:10

bdavidxyz