Testing in Web Development (week 11) Flashcards

1
Q

What are some examples of types of tests?

A

Unit tests, behavioural tests, acceptance tests, regression tests etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some of the different kinds of systems to test?

A

Safety-critical, embedded systems, real-time systems etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some examples of particular challenges for testing web applications (6)

A
  • Different browsers (FireFox, Chrome)
  • Different versions of browser (IE6 vs IE8)
  • Differences in versions of HTML, ECMAScript (JavaScript)
  • Differences in APIs e.g. how XHRs are handled by different browsers
  • Differences in the handling of the DOM, JavaScript etc.
  • Differences in libraries and versions (e.g. jQuery)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the advantages of automated testing? (10)

A
  • Automation means you can offload testing to machines (rather than rely on humans)
  • (More) frequent testing e.g. regression testing
  • Quick and regular feedback to developers
  • Virtually unlimited iterations of test case execution
  • Support for Agile and extreme development methodologies
  • Disciplined documentation of test cases
  • Customized defect reporting
  • Finding defects missed by manual testing
  • Humans get tired etc.
  • Supports continuous integration and continuous deployment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When should we not automate and manual instead on the <strong>client</strong> side?

A
  • If the user interface is rapidly changing
  • e.g. HTML elements are changing
  • Will need to keep changing the tests to match the interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When should we not automate and manual instead on the <strong>server</strong> side?

A

If the API is rapidly changing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Aside from specific and server side context, when should we not automate and manual instead?

A

Tight timescales –> Don’t have time to develop the tests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Discuss the developer’s comments to the failed automated test. What is the problem with the test?

Log in /authentication

Developer: ‘It works in my Postman test but fails the automated test’

•Assumption: that the log in details are sent via the body rather than the query

A

(… therefore there is a problem with the automated test)

  • Developer’s assumptions affect the developer’s coding
  • The same developer assumptions influence the developer’s Postman tests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Discuss the developer’s comments to the failed automated test. What is the problem with the test?

Photo uploading

Developer: ‘It works in my Postman test but fails the automated test’

A

(… therefore there is a problem with the automated test)

  • The way Postman attaches photos is different to the way that the mocha-chai framework attaches photos
  • Difference in ‘implementation’ of API specification
  • Difference/s in implementation used by developer and tester
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Discuss the developer’s comments to the failed automated test. What is the problem with the test?

Race conditions

Developer: ‘It works in my Postman test but fails the automated test’

A

(… therefore there is a problem with the automated test)

  • Postman tests (being manually driven*) operate in ‘human real-time’
  • Mocha-chai tests (being automated) operate in ‘computing real-time’
  • Difference in ability to replicate timing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Discuss the developer’s comments to the failed automated test. What is the problem with the test?

npmstart vs node app.js

Developer: ‘App runs in WebStorm but fails during the automated test’

A

(… therefore there is a problem with the automated test)

  • The IDE configuration may be different to the automated testing configuration
  • WebStorm: press the ‘run’ button which defaults to run node app.js
  • Automated test: uses npmstart
  • Differences in configuration
  • Differences in assumptions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Discuss the developer’s comments to the failed automated test. What is the problem with the test?

Photos directory

Developer: ‘App runs in WebStorm but fails the automated test’

A

(… therefore there is a problem with the automated test)

  • The developer created a /photos directory through WebStorm, but…
  • … (for whatever reason) the /photos directory and assets were not added to the git repo…
  • … so the server crashes when downloaded from eng-git and run
  • Differences in ‘environment’ (configuration)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Discuss the developer’s comments to the failed automated test. What is the problem with the test?

Developer: ‘When I run it, the test passes, but it fails the automated test…’

A

(… therefore there is a problem with the automated test)

  • Has the developer read the API specification properly?
  • Does the API specification explain itself properly?
  • Does the developer understand what is expected of the API?
  • Does the tester understand what is expected of the API?
  • The HTTP response from the API is not the same as a response to the user
  • API ≠ user story ≠ developer’s assumptions ≠ developer’s preferences
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define a false positive tests

A

Actually passes, but for the wrong reason

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define a false negative tests

A

Actually fails, but for the wrong reason

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List the four general sets of scenarios that can occur for tests.

A

Operation actually successful & Operation intended to be successful –> passing

Operation actually successful & Operation intended to be unsuccessful –> failing

Operation actually unsuccessful & Operation intended to be successful –> failing

Operation actually unsuccessful & Operation intended to be unsuccessful –> passing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How can we have independent tests?

A
  • One test failing does not affect another test’s success
  • Use pre-conditions to setup test e.g. before()
  • Use post-conditions to tidy up, after test e.g. after()

Use suites for different areas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Discuss reasons why we cannot always ensure tests are independent.

A
  • Some functionality will effect other functionality

* Login function is required before other functionality can operate –> •Could stub

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the ideal situation for a given test?

✨✨✨

A

Independent, discrete, specific tests.

•e.g. One test (one suite of tests) for each status code in the API

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a reason that, in reality, APIs are not always completely specified?

A

Minimal Viable Product

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the intent of using WebDriver API?

✨✨✨

A

Intended to enable web authors to write tests that automate a user agent using a separate controlling process.

–> •May also be used to allow in-browser scripts to control a (possibly separate) browser

22
Q

What are WebDriver API’s set of interfaces provided for?

A
  • discover and manipulate DOM elements in web documents; and

* to control the behavior of a user agent (a browser).

23
Q

What sort of protocol does WebDriver API provide? What is its purpose?

A

Provides a platform-neutral and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.

24
Q

What does WebDriver API form part of?

A

The W3C Web Testing Activity

25
Q

What does Selenium-WebDriver | Selenium 2.0 replace?

A

Replaces Selenium Remote Control

–> Webdriver has a very different approach to testing

26
Q

What are the two uses of Selenium automating a browser?

A
  • Use to automate testing

* Use to automate routine web tasks e.g. some admin task

27
Q

What does Selenium-WebDriver | Selenium 2.0 allow us to do?

A

Drive the browser (automatically) the way a user would

–> Automate what you want the user to do

–> Automate what you want the user not to do

–> Automate unintentional behaviour, accidental behaviour, stupid behaviour, risky behaviour(e.g. security attacks?)

28
Q

What was Selenium-WebDriver developed to better support?

A

automation of dynamic web pages,

–> •Dynamic pages: elements of a page may change without the page itself being reloaded. (What is a webpage?)

–> •Single Page Applications generate dynamic web pages

29
Q

What does WebDriver rely on?

What are some implications?

A

browser’s built-in (native) support for automation

–> •You’ll need an update-to-date browser

–> •Harder to automatically test older browsers

30
Q

Discuss the procedure for using Selenium WebDriver

A

1) write commands in native language (Java, .Net, Python, etc.)
2) Uses WebDriver to connect to browser and automates the actions within the browser –> uses RESTful API call between selenium & browser
3) Browser connects to web server

See image #32

31
Q

Outline the procedure for using the old Selenium Remote Controller

A

1) write commands in native language (Java, .Net, Python, etc)
2) Selenium RC Server used (NOT USED IN NEW SELENIUM 2.0)
3) Browser with Selenium CORE Injected
4) Web server

See image #33

32
Q

What does W3C stand for?

A

World Wide Web Consortium

33
Q

What must we do for cross-browser testing?

A

Automate your testing on different browsers

34
Q

Why must we automate our testing on different browsers in terms of cross-browser testing?

A

each browser has its own quirks and differences in their implementation of the DOM and in how JavaScript interacts with it.

(“When we say “JavaScript” we actually mean “JavaScript and the DOM”. Although the DOM is defined by the W3C each browser has its own quirks and differences in their implementation of the DOM and in how JavaScript interacts with it. HtmlUnit has an impressively complete implementation of the DOM and has good support for using JavaScript, but it is no different from any other browser: it has its own quirks and differences from both the W3C standard and the DOM implementations of the major browsers, despite its ability to mimic other browsers.”)

35
Q

Discuss the example of automated testing in image #34/35

A

TODO

36
Q

Give a summary of what you can do in terms of UI automated testing.

A
  • Fetch a page:
  • Locate a UI (DOM) element
  • Get text values
  • User input
  • Move between windows and frames
  • Popup dialogs
  • Navigation and history (may be harder in SPA)
  • Cookies
  • Drag and drop
37
Q

How do we navigate a page using WebDriver?

What dynamically generate pages?

A

•To navigate to a page:

driver.navigate().to(‘http://www.example.com’);

•But SPAs dynamically generate pages

38
Q

How do you fetch a page using WebDriver?

A

driver.get(‘http://www.google.com’);

39
Q

How can you locate a UI (DOM) element using WebDriver?

A

By ID:

  • letelement = driver.findElement(By.id(‘someID’));
  • Compare with JavaScript getElementById();
40
Q

Compare the WebDriver vs the Selenium-Server

A

TODO: BREAK UP

•You can use WebDriver without Selenium Server

(large package, can set up automate tests across different browsers or VMs)

–> Browser and tests will all run on the same machine

  • There are reasons to use the Selenium-Server with Selenium-WebDriver.
  • You are using Selenium-Grid to distribute your tests over multiple machines or virtual machines (VMs).
  • You want to connect to a remote machine that has a particular browser version that is not on your current machine.
  • You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver

–> HtmlUnit is a “GUI-Less browser for Java programs”

41
Q

Give the Selenium-Server set up.

A

See image #36

42
Q

What Javascript frameworks all have test utilities?

A

Vue, React, Angular, etc.

43
Q

What do the test utilities for Javascript frameworks all you to do?

A

run unit tests

44
Q

How can we ‘activate’ Vue Test Utils?

A

When creating Vueapp(vuecreate …) select custom features and “Unit Testing”

45
Q

What are test utilities for JavaScript frameworks agnostic in terms of?

A

test runner

  • -> Mochai/Chai
  • -> Jest
  • ——-> alternative, newer test runner
  • ——-> used in Vue documentation (and React as well)
46
Q

Explain the example test in Vue.js component - image #37

A

TODO

47
Q

What are the stages of testing Vue components?

A
  • Mount isolated component for testing
  • Three stages of testing:

1) Arrange: set up scenario for the test
2) Act: simulate user interaction with the component
3) Assert: make sure that the current state of the component matches what we expect

48
Q

Explain the stages of testing Vue components in terms of the example test - image #38

A

TODO

49
Q

What is a dynamic web page?

A

Elements of a page may change without the page itself being reloaded.

50
Q

Do single Page Applications generate dynamic web pages?

A

Yes