SlideShare a Scribd company logo
Dev in Bahia 1º First
Technical Meeting
What is Dev In Bahia ?
• Borned in 2012 through the #horaextra.
• Has the vision to transform our local IT Market in a better
place to work and to develop ourselves as IT Professionals.
• What we do ?
• Promote Events, Discussions, User groups and so on.
Technical Meetings
• We are trying to promete one since last year.
• Prevented by:
• Place
• People
• Schedule
• We want to promote a technical meeting once or twice a
month.
• Tech Talk + Coding Dojo
• Before each meeting, people will send talk suggestions and we
are going to vote to choose.
Who is Paulo Ortins ?
• Developer at Inteligência Digital
• Masters Student at UFBA ( Software Engineering)
• Blogger at www.pauloortins.com
• Newsletter Curater at dotnetpills.apphb.com
• Joined in the community in 2011
• Polyglot Programmer
• Founded Dev In Bahia and #horaextra
Twitter: @pauloortins
Github: pauloortins
1º Technical Meeting
• How create tests using Javascript ?
A test overview
• Monkey Tests
• Unit Tests
• End-to-End Tests
Monkey Tests
But Requirements Change
You do it again
Monkey Test [2]
But Requirements Change[2]
Monkey Test Division
Problems with Monkey Tests
• Low Reliability, people aren’t machines, they work has
variance.
• Expensive, people have to test the software everytime
something changes.
Super Kent Beck
Automated Tests
• Tests should be automated.
• Functionality are done if, and only if, there are automated
tests covering them.
Unit Tests
• Tests only a piece of code.
• Provide instantly feedback about our software.
• Help to improve code design.
Example
function isBetweenFiveAndTen(number) {
var isGreaterThanFive = number > 5;
var isLesserThanTen = number < 10;
return isGreaterThanFive && isLesserThanTen;
}
Input Output
5 False
6 True
7 True
10 False
End-to-end Tests
• Tests simulate a monkey test, covering browser interaction,
database access, business rules.
• Slower than unit tests.
• Let me show a example using Selenium WebDriver
Javascript
• Javascript is rising.
• Web more interactive and responsive.
• Applications like Facebook and Gmail.
• Web Apps ( PhoneGap, Ext.js, jquery mobile)
Unit tests in Javascript
• There are several options to create unit tests in Javascript:
• Qunit
• Mocha
• Jasmine
Jasmine
• Created due the dissatisfaction existing framworks by
PivotalLabs.
• Small library
• Easy to use
Suites
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
• Describe, name a test suite ou a set test.
• It, describe the test name.
Expectations
describe("The 'toBe' matcher compares with ===", function() {
it("and has a positive case ", function() {
expect(true).toBe(true);
});
it("and can have a negative case", function() {
expect(false).not.toBe(true);
});
});
• Comparisons made through matchers, who are predefined
functions who receives a value (actual) and compares with the
expected value.
• A lot of matchers are included.
Matchers
describe("The 'toEqual' matcher", function() {
it("works for simple literals and variables", function() {
var a = 12;
expect(a).toEqual(12);
});
it("should work for objects", function() {
var foo = {
a: 12,
b: 34
};
var bar = {
a: 12,
b: 34
};
expect(foo).toEqual(bar);
});
});
Matchers
it("The 'toMatch' matcher is for regular expressions", function() {
var message = 'foo bar baz';
expect(message).toMatch(/bar/);
expect(message).toMatch('bar');
expect(message).not.toMatch(/quux/);
});
Matchers
it("The 'toBeDefined' matcher compares against `undefined`",
function() {
var a = {
foo: 'foo'
};
expect(a.foo).toBeDefined();
expect(a.bar).not.toBeDefined();
});
Matchers
it("The 'toBeNull' matcher compares against null", function() {
var a = null;
var foo = 'foo';
expect(null).toBeNull();
expect(a).toBeNull();
expect(foo).not.toBeNull();
});
Matchers
it("The 'toBeTruthy' matcher is for boolean casting testing", function()
{
var a, foo = 'foo';
expect(foo).toBeTruthy();
expect(a).not.toBeTruthy();
});
it("The 'toBeFalsy' matcher is for boolean casting testing", function() {
var a, foo = 'foo';
expect(a).toBeFalsy();
expect(foo).not.toBeFalsy();
});
Matchers
it("The 'toContain' matcher is for finding an item in an Array",
function() {
var a = ['foo', 'bar', 'baz'];
expect(a).toContain('bar');
expect(a).not.toContain('quux');
});
Matchers
it("The 'toBeLessThan' matcher is for mathematical comparisons", function() {
var pi = 3.1415926, e = 2.78;
expect(e).toBeLessThan(pi);
expect(pi).not.toBeLessThan(e);
});
it("The 'toBeGreaterThan' is for mathematical comparisons", function() {
var pi = 3.1415926, e = 2.78;
expect(pi).toBeGreaterThan(e);
expect(e).not.toBeGreaterThan(pi);
});
it("The 'toBeCloseTo' matcher is for precision math comparison", function() {
var pi = 3.1415926, e = 2.78;
expect(pi).not.toBeCloseTo(e, 2);
expect(pi).toBeCloseTo(e, 0);
});
Matchers
it("The 'toThrow' matcher is for testing if a function throws an
exception", function() {
var foo = function() {
return 1 + 2;
};
var bar = function() {
return a + 1;
};
expect(foo).not.toThrow();
expect(bar).toThrow();
});
Custom Matchers
beforeEach(function() {
this.addMatchers({
isEven: function(number) {
return number % 2 === 0;
}
});
});
Setup/Teardown
describe("A spec (with setup and tear-down)", function() {
var foo;
beforeEach(function() {
foo = 0;
foo += 1;
});
afterEach(function() {
foo = 0;
});
it("is just a function, so it can contain any code", function() {
expect(foo).toEqual(1);
});
it("can have more than one expectation", function() {
expect(foo).toEqual(1);
expect(true).toEqual(true);
});
});
Let’s play with Jasmine
• Site
• Tutorial
• Standalone Version
Testacular/Karma
• Created by Google to test Angular.js
• Runs on top of Node.js
• Watch our JS files to detect changes and rerun the tests
Thank you!

More Related Content

What's hot

Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomas
intuit_india
 
Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017
Peter Thomas
 
Zero to Testing in JavaScript
Zero to Testing in JavaScriptZero to Testing in JavaScript
Zero to Testing in JavaScript
pamselle
 
Deploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember Application
Ben Limmer
 
TDD with phpspec2
TDD with phpspec2TDD with phpspec2
TDD with phpspec2
Anton Serdyuk
 
Pretenders talk at PyconUK 2012
Pretenders talk at PyconUK 2012Pretenders talk at PyconUK 2012
Pretenders talk at PyconUK 2012
txels
 
MidwestJS Zero to Testing
MidwestJS Zero to TestingMidwestJS Zero to Testing
MidwestJS Zero to Testing
pamselle
 
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It WrongController Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
johnnygroundwork
 
RSpec 2 Best practices
RSpec 2 Best practicesRSpec 2 Best practices
RSpec 2 Best practices
Andrea Reginato
 
Modern Functional Fluent ColdFusion REST Apis
Modern Functional Fluent ColdFusion REST ApisModern Functional Fluent ColdFusion REST Apis
Modern Functional Fluent ColdFusion REST Apis
Ortus Solutions, Corp
 
A Deep Dive into the W3C WebDriver Specification
A Deep Dive into the W3C WebDriver SpecificationA Deep Dive into the W3C WebDriver Specification
A Deep Dive into the W3C WebDriver Specification
Peter Thomas
 
Jasmine
JasmineJasmine
Jasmine
Alok Guha
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
Joseph Wilk
 
Karate - Web-Service API Testing Made Simple
Karate - Web-Service API Testing Made SimpleKarate - Web-Service API Testing Made Simple
Karate - Web-Service API Testing Made Simple
VodqaBLR
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
SQABD
 
Automated Testing in EmberJS
Automated Testing in EmberJSAutomated Testing in EmberJS
Automated Testing in EmberJS
Ben Limmer
 
TDD, BDD, RSpec
TDD, BDD, RSpecTDD, BDD, RSpec
TDD, BDD, RSpec
Nascenia IT
 
2010 07-20 TDD with ActiveResource
2010 07-20 TDD with ActiveResource2010 07-20 TDD with ActiveResource
2010 07-20 TDD with ActiveResource
Wolfram Arnold
 
The Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + AngularThe Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + Angular
Tracy Lee
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
Joseph Wilk
 

What's hot (20)

Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomas
 
Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017
 
Zero to Testing in JavaScript
Zero to Testing in JavaScriptZero to Testing in JavaScript
Zero to Testing in JavaScript
 
Deploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember Application
 
TDD with phpspec2
TDD with phpspec2TDD with phpspec2
TDD with phpspec2
 
Pretenders talk at PyconUK 2012
Pretenders talk at PyconUK 2012Pretenders talk at PyconUK 2012
Pretenders talk at PyconUK 2012
 
MidwestJS Zero to Testing
MidwestJS Zero to TestingMidwestJS Zero to Testing
MidwestJS Zero to Testing
 
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It WrongController Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
 
RSpec 2 Best practices
RSpec 2 Best practicesRSpec 2 Best practices
RSpec 2 Best practices
 
Modern Functional Fluent ColdFusion REST Apis
Modern Functional Fluent ColdFusion REST ApisModern Functional Fluent ColdFusion REST Apis
Modern Functional Fluent ColdFusion REST Apis
 
A Deep Dive into the W3C WebDriver Specification
A Deep Dive into the W3C WebDriver SpecificationA Deep Dive into the W3C WebDriver Specification
A Deep Dive into the W3C WebDriver Specification
 
Jasmine
JasmineJasmine
Jasmine
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
 
Karate - Web-Service API Testing Made Simple
Karate - Web-Service API Testing Made SimpleKarate - Web-Service API Testing Made Simple
Karate - Web-Service API Testing Made Simple
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
 
Automated Testing in EmberJS
Automated Testing in EmberJSAutomated Testing in EmberJS
Automated Testing in EmberJS
 
TDD, BDD, RSpec
TDD, BDD, RSpecTDD, BDD, RSpec
TDD, BDD, RSpec
 
2010 07-20 TDD with ActiveResource
2010 07-20 TDD with ActiveResource2010 07-20 TDD with ActiveResource
2010 07-20 TDD with ActiveResource
 
The Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + AngularThe Power of RxJS in Nativescript + Angular
The Power of RxJS in Nativescript + Angular
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
 

Viewers also liked

Como participar de comunidades de software mudou a minha carreira e também po...
Como participar de comunidades de software mudou a minha carreira e também po...Como participar de comunidades de software mudou a minha carreira e também po...
Como participar de comunidades de software mudou a minha carreira e também po...
Paulo Cesar Ortins Brito
 
GDG Dev Fest Extended - Mobilidade além do smartphone
GDG Dev Fest Extended - Mobilidade além do smartphoneGDG Dev Fest Extended - Mobilidade além do smartphone
GDG Dev Fest Extended - Mobilidade além do smartphone
Paulo Cesar Ortins Brito
 
Use Xamarin.Forms and surprise your customers when develop native apps, in le...
Use Xamarin.Forms and surprise your customers when develop native apps, in le...Use Xamarin.Forms and surprise your customers when develop native apps, in le...
Use Xamarin.Forms and surprise your customers when develop native apps, in le...
Paulo Cesar Ortins Brito
 
GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...
GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...
GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...
Paulo Cesar Ortins Brito
 
The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...
The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...
The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...
Paulo Cesar Ortins Brito
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
Lars Thorup
 

Viewers also liked (6)

Como participar de comunidades de software mudou a minha carreira e também po...
Como participar de comunidades de software mudou a minha carreira e também po...Como participar de comunidades de software mudou a minha carreira e também po...
Como participar de comunidades de software mudou a minha carreira e também po...
 
GDG Dev Fest Extended - Mobilidade além do smartphone
GDG Dev Fest Extended - Mobilidade além do smartphoneGDG Dev Fest Extended - Mobilidade além do smartphone
GDG Dev Fest Extended - Mobilidade além do smartphone
 
Use Xamarin.Forms and surprise your customers when develop native apps, in le...
Use Xamarin.Forms and surprise your customers when develop native apps, in le...Use Xamarin.Forms and surprise your customers when develop native apps, in le...
Use Xamarin.Forms and surprise your customers when develop native apps, in le...
 
GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...
GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...
GDG DevFest Nordeste - Quer desenvolver aplicações mobile nativas, cross-plat...
 
The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...
The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...
The Developer's Conference 2015 - Florianópolis - Use o Xamarin.Forms e surpr...
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
 

Similar to Tests in Javascript using Jasmine and Testacular

JavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfJavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdf
katarichallenge
 
Build a game with javascript (april 2017)
Build a game with javascript (april 2017)Build a game with javascript (april 2017)
Build a game with javascript (april 2017)
Thinkful
 
Welcome to React.pptx
Welcome to React.pptxWelcome to React.pptx
Welcome to React.pptx
PraveenKumar680401
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
Pascal Rettig
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
TJ Stalcup
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
Thinkful
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
Thinkful
 
Swift meetup22june2015
Swift meetup22june2015Swift meetup22june2015
Swift meetup22june2015
Claire Townend Gee
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
Andrzej Sitek
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
drewz lin
 
Creating a Responsive Website From Scratch
Creating a Responsive Website From ScratchCreating a Responsive Website From Scratch
Creating a Responsive Website From Scratch
Corky Brown
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
Thinkful
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
gturnquist
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
Mats Bryntse
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
masoodjan
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
Experience Session - Hari
Experience Session - HariExperience Session - Hari
Experience Session - Hari
SV.CO
 

Similar to Tests in Javascript using Jasmine and Testacular (20)

JavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfJavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdf
 
Build a game with javascript (april 2017)
Build a game with javascript (april 2017)Build a game with javascript (april 2017)
Build a game with javascript (april 2017)
 
Welcome to React.pptx
Welcome to React.pptxWelcome to React.pptx
Welcome to React.pptx
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 
Swift meetup22june2015
Swift meetup22june2015Swift meetup22june2015
Swift meetup22june2015
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Creating a Responsive Website From Scratch
Creating a Responsive Website From ScratchCreating a Responsive Website From Scratch
Creating a Responsive Website From Scratch
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Experience Session - Hari
Experience Session - HariExperience Session - Hari
Experience Session - Hari
 

More from Paulo Cesar Ortins Brito

GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...
GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...
GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...
Paulo Cesar Ortins Brito
 
TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...
TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...
TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...
Paulo Cesar Ortins Brito
 
Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...
Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...
Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...
Paulo Cesar Ortins Brito
 
Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...
Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...
Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...
Paulo Cesar Ortins Brito
 
Utilizando a API do Roslyn, o novo compilador do C#
Utilizando a API do Roslyn, o novo compilador do C#Utilizando a API do Roslyn, o novo compilador do C#
Utilizando a API do Roslyn, o novo compilador do C#
Paulo Cesar Ortins Brito
 
Métricas de Código
Métricas de CódigoMétricas de Código
Métricas de Código
Paulo Cesar Ortins Brito
 
Explicando conceitos de software usando situações do cotidiano
Explicando conceitos de software usando situações do cotidianoExplicando conceitos de software usando situações do cotidiano
Explicando conceitos de software usando situações do cotidiano
Paulo Cesar Ortins Brito
 
Mergulhando no ecossistema .NET
Mergulhando no ecossistema .NETMergulhando no ecossistema .NET
Mergulhando no ecossistema .NET
Paulo Cesar Ortins Brito
 
A vez do mobile - Dev in Bahia #3
A vez do mobile - Dev in Bahia #3A vez do mobile - Dev in Bahia #3
A vez do mobile - Dev in Bahia #3
Paulo Cesar Ortins Brito
 
SFD - C# para a comunidade
SFD - C# para a comunidadeSFD - C# para a comunidade
SFD - C# para a comunidade
Paulo Cesar Ortins Brito
 

More from Paulo Cesar Ortins Brito (10)

GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...
GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...
GDG Tech Talk - Quer desenvolver aplicações nativas e cross-plataforma usando...
 
TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...
TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...
TDC Porto Alegre 2014 - Quer desenvolver aplicações nativas e cross-plataform...
 
Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...
Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...
Semana Computação UFBA 2014 - Quer desenvolver aplicações nativas e cross-pla...
 
Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...
Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...
Semana Computação Unifacs 2014 - Quer desenvolver aplicações nativas e cross-...
 
Utilizando a API do Roslyn, o novo compilador do C#
Utilizando a API do Roslyn, o novo compilador do C#Utilizando a API do Roslyn, o novo compilador do C#
Utilizando a API do Roslyn, o novo compilador do C#
 
Métricas de Código
Métricas de CódigoMétricas de Código
Métricas de Código
 
Explicando conceitos de software usando situações do cotidiano
Explicando conceitos de software usando situações do cotidianoExplicando conceitos de software usando situações do cotidiano
Explicando conceitos de software usando situações do cotidiano
 
Mergulhando no ecossistema .NET
Mergulhando no ecossistema .NETMergulhando no ecossistema .NET
Mergulhando no ecossistema .NET
 
A vez do mobile - Dev in Bahia #3
A vez do mobile - Dev in Bahia #3A vez do mobile - Dev in Bahia #3
A vez do mobile - Dev in Bahia #3
 
SFD - C# para a comunidade
SFD - C# para a comunidadeSFD - C# para a comunidade
SFD - C# para a comunidade
 

Recently uploaded

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 

Recently uploaded (20)

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 

Tests in Javascript using Jasmine and Testacular

  • 1. Dev in Bahia 1º First Technical Meeting
  • 2. What is Dev In Bahia ? • Borned in 2012 through the #horaextra. • Has the vision to transform our local IT Market in a better place to work and to develop ourselves as IT Professionals. • What we do ? • Promote Events, Discussions, User groups and so on.
  • 3. Technical Meetings • We are trying to promete one since last year. • Prevented by: • Place • People • Schedule • We want to promote a technical meeting once or twice a month. • Tech Talk + Coding Dojo • Before each meeting, people will send talk suggestions and we are going to vote to choose.
  • 4. Who is Paulo Ortins ? • Developer at Inteligência Digital • Masters Student at UFBA ( Software Engineering) • Blogger at www.pauloortins.com • Newsletter Curater at dotnetpills.apphb.com • Joined in the community in 2011 • Polyglot Programmer • Founded Dev In Bahia and #horaextra Twitter: @pauloortins Github: pauloortins
  • 5. 1º Technical Meeting • How create tests using Javascript ?
  • 6. A test overview • Monkey Tests • Unit Tests • End-to-End Tests
  • 9. You do it again
  • 13. Problems with Monkey Tests • Low Reliability, people aren’t machines, they work has variance. • Expensive, people have to test the software everytime something changes.
  • 15. Automated Tests • Tests should be automated. • Functionality are done if, and only if, there are automated tests covering them.
  • 16. Unit Tests • Tests only a piece of code. • Provide instantly feedback about our software. • Help to improve code design.
  • 17. Example function isBetweenFiveAndTen(number) { var isGreaterThanFive = number > 5; var isLesserThanTen = number < 10; return isGreaterThanFive && isLesserThanTen; } Input Output 5 False 6 True 7 True 10 False
  • 18. End-to-end Tests • Tests simulate a monkey test, covering browser interaction, database access, business rules. • Slower than unit tests. • Let me show a example using Selenium WebDriver
  • 19. Javascript • Javascript is rising. • Web more interactive and responsive. • Applications like Facebook and Gmail. • Web Apps ( PhoneGap, Ext.js, jquery mobile)
  • 20. Unit tests in Javascript • There are several options to create unit tests in Javascript: • Qunit • Mocha • Jasmine
  • 21. Jasmine • Created due the dissatisfaction existing framworks by PivotalLabs. • Small library • Easy to use
  • 22. Suites describe("A suite", function() { it("contains spec with an expectation", function() { expect(true).toBe(true); }); }); • Describe, name a test suite ou a set test. • It, describe the test name.
  • 23. Expectations describe("The 'toBe' matcher compares with ===", function() { it("and has a positive case ", function() { expect(true).toBe(true); }); it("and can have a negative case", function() { expect(false).not.toBe(true); }); }); • Comparisons made through matchers, who are predefined functions who receives a value (actual) and compares with the expected value. • A lot of matchers are included.
  • 24. Matchers describe("The 'toEqual' matcher", function() { it("works for simple literals and variables", function() { var a = 12; expect(a).toEqual(12); }); it("should work for objects", function() { var foo = { a: 12, b: 34 }; var bar = { a: 12, b: 34 }; expect(foo).toEqual(bar); }); });
  • 25. Matchers it("The 'toMatch' matcher is for regular expressions", function() { var message = 'foo bar baz'; expect(message).toMatch(/bar/); expect(message).toMatch('bar'); expect(message).not.toMatch(/quux/); });
  • 26. Matchers it("The 'toBeDefined' matcher compares against `undefined`", function() { var a = { foo: 'foo' }; expect(a.foo).toBeDefined(); expect(a.bar).not.toBeDefined(); });
  • 27. Matchers it("The 'toBeNull' matcher compares against null", function() { var a = null; var foo = 'foo'; expect(null).toBeNull(); expect(a).toBeNull(); expect(foo).not.toBeNull(); });
  • 28. Matchers it("The 'toBeTruthy' matcher is for boolean casting testing", function() { var a, foo = 'foo'; expect(foo).toBeTruthy(); expect(a).not.toBeTruthy(); }); it("The 'toBeFalsy' matcher is for boolean casting testing", function() { var a, foo = 'foo'; expect(a).toBeFalsy(); expect(foo).not.toBeFalsy(); });
  • 29. Matchers it("The 'toContain' matcher is for finding an item in an Array", function() { var a = ['foo', 'bar', 'baz']; expect(a).toContain('bar'); expect(a).not.toContain('quux'); });
  • 30. Matchers it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; expect(e).toBeLessThan(pi); expect(pi).not.toBeLessThan(e); }); it("The 'toBeGreaterThan' is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; expect(pi).toBeGreaterThan(e); expect(e).not.toBeGreaterThan(pi); }); it("The 'toBeCloseTo' matcher is for precision math comparison", function() { var pi = 3.1415926, e = 2.78; expect(pi).not.toBeCloseTo(e, 2); expect(pi).toBeCloseTo(e, 0); });
  • 31. Matchers it("The 'toThrow' matcher is for testing if a function throws an exception", function() { var foo = function() { return 1 + 2; }; var bar = function() { return a + 1; }; expect(foo).not.toThrow(); expect(bar).toThrow(); });
  • 32. Custom Matchers beforeEach(function() { this.addMatchers({ isEven: function(number) { return number % 2 === 0; } }); });
  • 33. Setup/Teardown describe("A spec (with setup and tear-down)", function() { var foo; beforeEach(function() { foo = 0; foo += 1; }); afterEach(function() { foo = 0; }); it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); it("can have more than one expectation", function() { expect(foo).toEqual(1); expect(true).toEqual(true); }); });
  • 34. Let’s play with Jasmine • Site • Tutorial • Standalone Version
  • 35. Testacular/Karma • Created by Google to test Angular.js • Runs on top of Node.js • Watch our JS files to detect changes and rerun the tests