Introduction to Unit Testing in JavaScript

Slides:



Advertisements
Similar presentations
Kapil Mohan Sharma DMG - QA
Advertisements

Introduction to Unit Testing Svetlin Nakov Telerik Corporation
Acceptance Testing.
Test-Driven Development. Why Testing is Important? “If you don’t have tests, how do you know your code is doing the thing right and doing the right thing?”
Testing by Duncan Butler Sara Stephens. Too much to cover.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Applied Software Project Management Andrew Stellman & Jennifer Greene Applied Software Project Management Applied Software.
With Mocha and Karma Telerik Academy Telerik Software Academy.
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Zero to Testing in JavaScript Basics of testing in JS.
Background The Encyclopedio of Life (EOL) is an ROR open source project to create a free, online reference source and database for every one of the 1.8.
Introduction to Unit Testing Jun-Ru Chang 2012/05/03.
Testing in Extreme Programming
Unit Testing and Mocking
Code Correctness, Readability, Maintainability Telerik Software Academy Telerik School.
Building Rock-Solid Software Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Introduction to Testing 1. Testing  testing code is a vital part of the development process  the goal of testing is to find defects in your code  Program.
Jasmine Testing Framework. What’s Jasmine For? Framework for Test Driven Development Designed around acceptance testing Works in any environment (with.
Design and Programming Chapter 7 Applied Software Project Management, Stellman & Greene See also:
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Improving the Quality of Existing Code Svetlin Nakov Telerik Corporation
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
Unit Testing Building Rock-Solid Software SoftUni Team Technical Trainers Software University
Unit Tests Руслан Трифонов Omegasoft Ltd.. Съдържание 1.Въведение 2.Unit test patterns 2.1. Pass/fail patterns 2.2. Collection management patterns 2.3.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
Using Test Driven Development Jon Kruger Blog: Twitter: JonKruger.
Unit Testing in JavaScript with Mocha, Chai and Karma SoftUni Team Technical Trainers Software University
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
(1) Test Driven Development Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
Unit Testing Building Rock-Solid Software Svetlin Nakov Technical Trainer Software University
JavaScript Unit Test by MinHo Kim (Dexter Developer Guide)
High-Quality Code: Course Introduction Course Introduction SoftUni Team Technical Trainers Software University
Test Driven Development Introduction Issued date: 8/29/2007 Author: Nguyen Phuc Hai.
Northwest Arkansas.Net User Group Jay Smith Tyson Foods, Inc. Unit Testing nUnit, nUnitAsp, nUnitForms.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Unit testing with NUnit Anne Lam & Chris James CMPS 4113 – Software Engineering April 15, 2015.
Automated Testing with PHPUnit. How do you know your code works?
Unit testing of the Services Telerik Software Academy Web Services and Cloud.
UNIT TESTING IN ANGULARJS Dhananjay
QA Process within OEM Services Ethan Chang QA Engineer OEM Service, Canonical
Software Testing Kobla Setriakor Nyomi Faculty Intern (Programming II)
Leverage your Business with Selenium Automation Testing
Building Rock-Solid Software
Unit Testing - solid fundamentals
Visual FoxPro Controls
Unit Testing with Mocha
Software Packaging and Releasing
MVC Architecture, Symfony Framework for PHP Web Apps
Accessibility into Automation
Testing Process Roman Yagodka ISS Test Leader.
Quality Assurance: Early Work Items
Extending functionality using Collections
More On Testing Why, Where, How, When.
Unit Testing in a Team Sparkhound Presents by Steve Schaneville
Lunch & Learn: Are you letting your users be your testers?
Component Testing (Unit Testing)
TDD adoption plan 11/20/2018.
Design and Programming
Test-driven development (TDD)
Testing and Test-Driven Development CSC 4700 Software Engineering
CS240: Advanced Programming Concepts
Data Structures and Algorithms for Information Processing
Testing Acknowledgement: Original slides by Jory Denny.
Test and Verify Instances with DBAchecks
Test Driven Lasse Koskela Chapter 9: Acceptance TDD Explained
HCL’s Viewpoint – DevOps on MS Cloud
You’ll get better code in less time (If you do it for a while)
Test-Driven Development
Telerik Testing Framework
Visual FoxPro Controls
Presentation transcript:

Introduction to Unit Testing in JavaScript Basic Unit Testing JavaScript OOP Telerik Software Academy http://academy.telerik.com

Table of Contents Mocha HTML Reporter and Karma Unit Testing Overview Test-driven & behavior-driven development Mocha & Chai Overview and installation Running simple tests Mocha HTML Reporter and Karma Creating a test suites and specs

What is Unit Testing?

* Unit Test – Definition A unit test is a piece of code written by a developer that exercises a very small, specific area of functionality of the code being tested. “Program testing can be used to show the presence of bugs, but never to show their absence!” Edsger Dijkstra, [1972]

Manual Testing You have already done unit testing Manually, by hand Manual tests are less efficient Not structured Not repeatable Not on all your code Not easy to do as it should be

Unit Test – Example function sum(numbers) { var sum = 0; for (var i=0; i < numbers.length; i++) sum += array[i]; return sum; } function testSum() if (sum([1,2]) != 3) throw new Error('1+2 != 3'); if (sum([-2]) != -2) throw new Error('-2 != -2'); if (sum([]) != 0) throw new Error('0 != 0');

Unit Testing – Some Facts Tests are specific pieces of code In most cases unit tests are written by developers, not by QA engineers Unit tests are released into the code repository (TFS / SVN / Git) along with the code they test Unit testing framework is needed QUnit, Jasmine, Mocha

Unit Testing – More Facts All objects should be tested All methods should be tested Trivial code may be omitted E.g. property getters and setters Private methods can be omitted Some gurus recommend to never test private methods  this can be debatable Ideally all unit tests should pass before check- in into the source control repository

Why Unit Tests? Unit tests dramatically decrease the number of defects in the code Unit tests improve design Unit tests are good documentation Unit tests reduce the cost of change Unit tests allow refactoring Unit tests decrease the defect-injection rate due to refactoring / changes

Unit Testing in JavaScript http://academy.telerik.com