{"id":16352,"date":"2019-10-22T19:11:43","date_gmt":"2019-10-22T19:11:43","guid":{"rendered":"https:\/\/applitools.com\/blog\/?p=6352"},"modified":"2022-03-22T09:00:45","modified_gmt":"2022-03-22T16:00:45","slug":"functional-test-myopia","status":"publish","type":"post","link":"https:\/\/applitools.com\/blog\/functional-test-myopia\/","title":{"rendered":"Functional Test Myopia"},"content":{"rendered":"

Myopia means nearsightedness. If you write functional tests, you likely suffer from functional test myopia. You focus on your expected outcome and your test coverage. But you miss the big picture.<\/p>\n

We all know the joke about one night with a guy on his knees under a streetlamp. As he\u2019s fumbling around, a passerby notices him.<\/p>\n

\u201cSir,\u201d says the passerby, \u201cWhat are you doing down there?\u201d<\/p>\n

\u201cI\u2019m looking for my wallet,\u201d replies the guy.<\/p>\n

\u201cWhere did you lose it?\u201d asks the passerby.<\/p>\n

\u201cDown there, I think,\u201d says the guy, pointing to a place down the darkened street.<\/p>\n

\u201cWhy are you looking here, then?\u201d wonders the passerby.<\/p>\n

\u201cAh,\u201d says the guy, \u201cI can see here.\u201d<\/p>\n

\"1<\/p>\n

Source: http:\/\/first-the-trousers.com\/hello-world\/<\/a><\/p>\n

This is the case for functional testing<\/a> of your web app. You test what you expect to see. But your functional tests can\u2019t see beyond their code to the daylight of the rendered browser.<\/p>\n

What Are Your Goals For Web App Testing?<\/h2>\n

Let me start by asking you – what goals do you set for your web app testing?<\/p>\n

Have you ever wondered, if you\u2019re building a web app, why do you bother using a browser to test the app? If you\u2019re testing whether the app responds correctly to inputs and selectors, why not test using curl<\/a>\u00a0or a text-based browser like Browsh<\/a>?<\/p>\n

\"\"<\/p>\n

I\u2019m being ironic. You know that the browser renders your app, and you want to make sure your app renders correctly.<\/p>\n

But think about it: a text-based browser that converts web pages into something out of Minecraft will still pass a functional test — even if those pages are not rendered properly. That shows how limited traditional functional testing tools are.<\/p>\n

I ask this question not to trip you up, but to help clarify your expectations.<\/p>\n

In my experience, functional testers look for proper functionality for proper data input, handling data input exception cases, handling workflow exceptions, and handling server exceptions.<\/p>\n

Whatever your goals, when you test your applications, you expect to see the application behave as expected when handling both normal and exception cases. You hope to cover as much of the app code as possible, and you want to validate that the app works as designed.<\/p>\n

Why Functional Test Automation can fail<\/h2>\n

Functional testing myopia results from the code-based nature of functional testing. \u00a0To drive web app activity, most engineers use appropriate technology, such as Selenium WebDriver<\/a>. Selenium suits this need quite well. Other tools, like Cypress<\/a>, can drive the application.<\/p>\n

Similarly, a code-based tool evaluates the application response in HTML. TestNG<\/a>, JUnit<\/a>, Cypress, or some other tool inspects the DOM<\/a>\u00a0for an exact or relative locator<\/a>\u00a0that matches the coder\u2019s intended response and validates that:<\/p>\n