¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

W9: Testing

Emma Tysk Webdev Inglés 24 fichas

W9: Testing

Fichas del conjunto (24)

  1. 1What are three important reasons to test?Error Free Code - the goal is: bug free.
    Predictable - when we execute a functionality the outcomes are as we intended to be. Not only the first time - but always.
    Resilient to changes - being able to handle changes to functioanlities.
  2. 2What is BDD?Agile software development process which focuses the testing on the behaviour of the system from the perspective of the end-users.
  3. 3What is TDD?a software engineering practice that requires unit tests to be written before the code they are supposed to validate
  4. 4Draw the test-diagramDraw the test-diagram
  5. 5What is Mocha?Mocha is a javascript test framework running on Node.js and in the browser, that provides functions that are executed according in a specific order, and that logs their results to the terminal window.
    We can use Mocha to run any type of test we like within describe functions by adding code and assertions to determine a pass or fail status.
  6. 6What is Chai?Chai is an assertion library that is often used alongside Mocha. It provides functions and methods that help you compare the output of a certain test with its expected value
  7. 7What is Sinon?Sinon helps eliminate complexity in tests by allowing you to create so called test-doubles. For example it lets you wrap functions in spies or substitute them with stubs.
    Very useful when can’t test/touch the production code or you don't have a database to test with.
  8. 8Name three common test doublesSpy
    Mock
    Stub
  9. 9What is Istanbul?test coverage tool.
    You can see How much of your code was actually tested during tests
    Strive for 100% coverage!
  10. 10Name three test typesUnit
    Integration test
    Functional / end to end
  11. 11Write a simple Mocha assert. When a number in the array 'numbers' isn't present, -1 should be returnvar assert = require('assert');
    describe('Array', function() {
    describe('#indexOf()', function() {
    it('should return -1 when the value is not present', function() {
    assert.equal([1, 2, 3].indexOf(4), -1);
    });
    });
    });
  12. 12What is a unit test?testing where individual units of a software are tested. The purpose is to validate that each unit of the software performs as designed.
  13. 13What is Integrations test?individual units are combined and tested as a group. The purpose is to expose faults in the interaction between integrated units.
  14. 14Functional / end to end testA technique used to test whether the flow of an application right from start to finish is behaving as expected.
    It could be for a single system like the process of sending an email or it could be used where multiple systems are involved for example a student registering for a test, taking the test and then finally receiving his/her scores
  15. 15What are three things you can always test with a function?1.Test without arguments (what happens when a user doesn’t enter any arguments?)
    2.Test with valid arguments
    3.Test with invalid arguments
  16. 16Write an "expect" statement in chai which checks if the array numbers = [1, 2, 3, 4, 5] contains 2var expect = require('chai').expect;
    var numbers = [1, 2, 3, 4, 5];
    expect(numbers).to.be.an('array').that.includes(2);
  17. 17Write a test which checks if a functions throws an error if no arguments are passeddescribe('#testing the findSum() function', function() {
    context('test without arguments', function() {
    it('findSum() should throw error', function() {
    expect(function() {
    sum.findSum()
    }).to.throw(TypeError, 'findSum() expects numbers.')
    })
    })
  18. 18Write a test which checks if a functions returns a sum of two numbers as expectedcontext('test with two arguments', function() {
    it('findSum(n1,n2) should return sum of n1 and n2', function() {
    expect(sum.findSum(1, 2)).to.equal(3)
    })
    })
  19. 19what are test doubles?block of code that replaces some portion of code for testing purposes. Useful when you can’t test/touch production code. It can also simplify testing
  20. 20What is a Spy?A spy is a test double that can provide
    information about functions. For example, how many times were they called, in which cases, and by whom?
  21. 21What is a stub?A stub replaces the real function with the behavior you specify.
    Stubs can be used to replace code that makes writing tests difficult. For example we can write stubs to simulate database related behaviours when we don't have a database setup.
  22. 22How do you use Node.js assert?var assert = require('assert');
    assert.equal(50, 50);
  23. 23Functions syntax of "strict equal" in CHaiassert.strictEqual(true, true, 'these booleans are strictly equal');
    strictEqual(actual, expected, [message])
  24. 24What is the difference between Mocha and Chai?Mocha is a test framework while Chai is an expectation one. Let’s say Mocha sets up and describes test suites and Chai provides convenient helpers to perform all kinds of assertions against your JavaScript code.

Información

Descripción
Webdev Fichas sobre W9: Testing, creado por Emma Tysk el 18/06/2019.
Creado por
Emma Tysk
Visitas
2
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?