SlideShare a Scribd company logo
TEST DRIVEN
DEVELOPMENT
TIMOTHY BOLTON
Test Driven Development
•What is TDD?
•Why use TDD?
•How to use TDD?
•When to stray from TDD?
•Super Simple Sample of TDD
•Recap
What is TDD?
•Development “driven” by testing.
–Tests are written before code is.
–Tests should initially fail
–Production code should be enough to pass
•A simple philosophy
•A great way to make you feel superior
Why use TDD?
•It makes refactoring very simple.
•It gives you confidence
•It helps create a scope of work
•It creates a baseline
•It helps you document your project
•It helps bring new developers up to speed
How to use TDD?
•There are 3 Rules
1.No production code unless it makes a failing
test pass.
2.No more of a unit test written than is sufficient
to make it fail.
3.No more production code is written than is
sufficient to pass the one failing unit test.
How to use TDD cont’d
•Build your own tools
–My Environment consists of:
•Vim
•Tmux
•watchTests.sh Script
•Inotifywait
When to stray from TDD?
•Ideally, “never”
•Realistically?
–Working on a pre-existing project
–Working in a language where TDD frameworks
are not established
–When tests take too long. It’s the truth. :’(
Super Simple Sample of TDD
•Email address availability with pure
MivaScript and JavaScript
•Remember
–We don’t have a lot of time
–We won’t write a lot of tests for MivaScript
–We don’t have tools built for Mocking
•https://bitbucket.org/snippets/timothybolton/BdL8
Super Simple Sample Cont’d
•Where to start?
–MivaScript
•Create a simple “AssertTrue” function
•Create a simple queryEmailTests.mv file
–Put some lipstick on that pig with formatting
–Write the first test
•Create production code
Super Simple Sample Cont’d
•What are we trying to accomplish?
See if an email address is used already
•Moving parts and external dependencies
–Database Connection
–Data in Database
–Network Connection
Super Simple Sample Cont’d
MivaScript “AssertEqual” function
While we certainly don't need a function to do this, as
we can make simple assertions with “MvIF” statements, it
makes the code easier to read and communicates the
intention.
Other Assertions
AssertTrue, AssertFalse, AssertNull, AssertNotNull
AssertNotEqual, AssertIsDigit, AssertIsAlpha, etc.
Be creative. Work together. Write better scripts.
Super Simple Sample Cont’d
FILE NAME: mvassert.mv
1 <MIVA STANDARDOUTPUTLEVEL = "text, compresswhitespace">
2 <MvFUNCTION NAME = "AssertEqual" PARAMETERS = "expected, actual" STANDARDOUTPUTLEVEL="" ERROROUTPUTLEVEL="">
3 <MvFUNCTIONRETURN VALUE = "{ l.expected EQ l.actual }">
4 </MvFUNCTION>
Super Simple Sample Cont’d
FILE NAME: mvTestLibrary.mv
1 <MIVA STANDARDOUTPUTLEVEL = "html, compresswhitespace">
2
3 <MvFUNCTION NAME = "generateTestResults" STANDARDOUTPUTLEVEL = "html, compresswhitespace">
4 <MvEVAL EXPR = "{ buildViewStart() }">
5
6 <MvFOR INDEX = "l.pos" FIRST = "{ 1 }" NEXT = "{ ++l.pos }" LAST = "{ g.currentTestNumber }">
7 <MvASSIGN NAME = "l.currentTestStatusStyle" VALUE = "{
generateTestStatusStyle(g.testResults[l.pos]:status) }">
8 <MvEVAL EXPR = "{ generateTestRowData(g.testResults[l.pos]:name, l.currentTestStatusStyle) }">
9 </MvFOR>
10 <MvEVAL EXPR = "{ buildViewEnd() }">
11 </MvFUNCTION>
12
13 <MvFUNCTION NAME = "generateTestRowData" PARAMETERS = "name, style" STANDARDOUTPUTLEVEL =
"compresswhitespace">
14 <MvIF EXPR = "{ g.source EQ 'curlVim' }">
15 <MvASSIGN NAME = "l.view" VALUE = "{ generateTestRowDataCli(l.name, l.style) }">
16 <MvELSE>
17 <MvASSIGN NAME = "l.view" VALUE = "{ generateTestRowDataHtml(l.name, l.style) }">
18 </MvIF>
19 <MvFUNCTIONRETURN VALUE = "{ l.view }">
20 </MvFUNCTION>
21
22 <MvFUNCTION NAME = "generateTestRowDataHtml" PARAMETERS = "name, style" STANDARDOUTPUTLEVEL =
"compresswhitespace">
23 <MvFUNCTIONRETURN VALUE = "{ '<tr><td>' $ l.style $ '</td><td>' $ l.name $ '()</td></tr>' }">
24 </MvFUNCTION>
25
26 <MvFUNCTION NAME = "generateTestRowDataCli" PARAMETERS = "name, style" STANDARDOUTPUTLEVEL =
"compresswhitespace">
27 <MvFUNCTIONRETURN VALUE = "{ '
28 ' $ l.style $ ' ' $ l.name $ '()' }">
29 </MvFUNCTION>
30
31 <MvFUNCTION NAME = "buildViewEnd">
32 <MvIF EXPR = "{ g.source EQ 'curlVim' }">
Super Simple Sample Cont’d
FILENAME:queryEmailTests.mv
1 <MIVA STANDARDOUTPUTLEVEL = "text">
2 <MvINCLUDE FILE = "mvassert.mv">
3 <MvINCLUDE FILE = "mvTestLibrary.mv">
4 <MvINCLUDE FILE = "queryEmailFunctions.mv">
5 <MvASSIGN NAME = "g.currentTestNumber" VALUE = 0>
7 <MvCOMMENT>Tests are run here</MvCOMMENT>
8 <MvASSIGN NAME = "l.result" VALUE = "{ testEmailAvailableOnAddress() }">
10 <MvEVAL EXPR = "{ generateTestResults() }">
11 <MvEXIT>
13 <MvCOMMENT>Tests are written here</MvCOMMENT>
14 <MvFUNCTION NAME = "testEmailAvailableOnAddress" STANDARDOUTPUTLEVEL = "compresswhitespace">
15 <MvASSIGN NAME = "g.currentTestNumber" VALUE = "{ ++g.currentTestNumber }">
16 <MvASSIGN NAME = "g.testResults" MEMBER = "status" INDEX = "{ g.currentTestNumber }" VALUE = "{
AssertEqual(1, CheckEmailAvailable('jimmy@jon.net')) }">
17 <MvASSIGN NAME = "g.testResults" MEMBER = "name" INDEX = "{ g.currentTestNumber }" VALUE = "{
'testEmailAvailableOnAddress' }">
18 </MvFUNCTION>
Super Simple Sample Cont’d
Vim integration (put in your .vimrc, and
validate for your sites)
nnoremap <Leader>ca :! mvc % && curl -T %c ftp://ftp.mivamerchantdev.com/mm5/5.00/modules/util/ -u
bolton.timothy@gmail.com@dts2639.mivamerchantdev.com:$MIVAPASSWORD && clear && curl
http://dts2639.mivamerchantdev.com/mm5/5.00/modules/util/%c?Store_Code=MIVA_DEV&source=curlVim<CR>
Super Simple Sample Cont’d
We have our first test, let's try to run it.
What do you think will happen?
That's right… it won't work.
We need to write our production function.
Super Simple Sample Cont’d
Boiler Plate Code
FILENAME: queryEmailFunctions.mv
1 <MIVA STANDARDOUTPUTLEVEL = "text, compresswhitespace">
2 <MvCOMMENT> 99% of this code is from the LSK or the fora.</MvCOMMENT>
3 <MvDO FILE = "../../lib/config.mvc">
4
5 <MvIF EXPR = "{ NOT [ '../../lib/db.mvc' ].OpenDataFiles( g.Merchant_Version, g.Domain ) }">
6 <MvEXIT>
7 </MvIF>
8
9 <MvEVAL EXPR = "{ [ '../../lib/util.mvc' ].SetRuntimePaths() }">
10
11 <MvIF EXPR = "{ NOT [ g.Module_Library_DB ].Store_Open( g.Store_Code, g.Store ) }">
12 <MvIF EXPR = "{ NOT g.Store_Code }"> <MvEVAL EXPR = "{ 'YOU NEED TO SUPPLY g.Store_Code' }"> </MvIF>
13 <MvEXIT>
14 </MvIF>
Super Simple Sample Cont’d
16 <MvFUNCTION NAME = "CheckEmailAvailable" PARAMETERS = "email" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL =
"">
17 <MvOPENVIEW NAME = "Merchant"
18 VIEW = "Customers"
19 QUERY = "{ 'SELECT COUNT(*) AS emailUsed '
20 $ 'FROM ' $ g.Store_Table_Prefix $ 'Customers '
21 $ 'WHERE ' $ [ g.Module_Library_Native_DBAPI ].DB_Compare_UPPER( 'pw_email' )
22 $ ' = '
23 $ [ g.Module_Library_Native_DBAPI ].DB_Compare_UPPER( '?' ) }"
24 FIELDS = "l.email">
25 <MvIF EXPR = "{ Customers.d.emailUsed GT 0 }">
26 <MvASSIGN NAME = "l.returnValue" VALUE = "0">
27 <MvELSE>
28 <MvASSIGN NAME = "l.returnValue" VALUE = "1">
29 </MvIF>
30 <MvCLOSEVIEW NAME = "Merchant" VIEW = "Customers" >
31 <MvFUNCTIONRETURN VALUE = "{l.returnValue }">
32 </MvFUNCTION>
Super Simple Sample Cont’d
What happens when we run now?
Using our Vim plugin, we can run from within
our editor, from the CLI, or via the web. The
mvTestFramework has detection from passed
in parameters, to see the output we specify.
Super Simple Sample Cont’d
Separation
Separation function declarations from side-effects
This make testing easier
Our compiled script
1 <MIVA STANDARDOUTPUTLEVEL = "text, compresswhitespace">
2 <MvINCLUDE FILE="queryEmailFunctions.mv">
4 <MvEVAL EXPR = "{ CheckEmailAvailable(g.username) }">
5 <MvEXIT>
Super Simple Sample Cont’d
Test again.
Now we can rinse and repeat with another
test.
Super Simple Sample Cont’d
JavaScript Testing
Ajax can be difficult without mocking, or
using synchronous calls. Which would then be
“Jax”… because, there is no 'A'.
This is depreciated because it degrades the
user experience, but it can be useful for
testing.
Super Simple Sample Cont’d
Our simple assertion library will leverage
some of the console behavior that comes with
Chrome and other browsers.
We will just create a simple tdd page that we
can protect.
Super Simple Sample Cont’d
1 var testAjax = new XMLHttpRequest();
2
3 testAjax.onreadystatechange = function() {
4 if(testAjax.readyState == 4 && testAjax.status == 200) {
5 return parseInt(testAjax.responseText);
6 }
7 }
8
9 function testAvailableEmail(email) {
10 testAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + email, false);
11 testAjax.send();
12 return { "test": arguments.callee.name,
13 "actual": testAjax.responseText,
14 "expected": 1
15 };
16 }
17
18 function testUnavailableEmail(email) {
19 testAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + email, false);
20 testAjax.send();
21 return { "test": arguments.callee.name,
22 "actual": testAjax.responseText,
23 "expected": 0
24 };
25 }
26
27 var testInformation = new Array();
28
29 testInformation.push(testAvailableEmail('notused@example.com'));
30 testInformation.push(testUnavailableEmail('bolton.timothy@gmail.com'));
31
32 for(var i = 0; i < testInformation.length; i++) {
33 console.assert(testInformation[i].actual == testInformation[i].expected, testInformation[i].test + '
Failed. '
34 + 'Actual: ' + testInformation[i].actual + '. Expected: ' + testInformation[i].expected );
35 }
Super Simple Sample Cont’d
17 function testUnavailableEmail(email) {
18 testAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + email, false);
19 testAjax.send();
20 return { "test": arguments.callee.name,
21 "actual": testAjax.responseText,
22 "expected": 0 };
23 }
Super Simple Sample Cont’d
27 testInformation.push(testAvailableEmail('notused@example.com'));
28 testInformation.push(testUnavailableEmail('bolton.timothy@gmail.com'));
29
30 for(var i = 0; i < testInformation.length; i++) {
31 console.assert(testInformation[i].actual == testInformation[i].expected,
32 testInformation[i].test + ' Failed. '
33 + 'Actual: ' + testInformation[i].actual + '. Expected: ' + testInformation[i].expected );
34 }
Super Simple Sample Cont’d
We are ready to put up some production
code now.
Super Simple Sample Cont’d
1 var newAjax = new XMLHttpRequest();
2
3 newAjax.onreadystatechange = function() {
4 if(newAjax.readyState == 4 && newAjax.status == 200) {
5 responseAction(newAjax.responseText);
6 }
7 }
8
9 var email = document.getElementById('Customer_LoginEmail');
10
11 email.onchange = function() {
12 newAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + this.value);
13 newAjax.send();
14 }
15
16 function responseAction(response) {
17 var alertText = "";
18 if(parseInt(response) == 0) {
19 alertText = "That username is unavailable";
20 } else {
21 alertText = "that username is available";
22 }
23 alert(alertText);
24 }
Super Simple Sample Cont’d
We are ready to put up some production
code now.
We have successfully test driven developed.
Exercises
Refactor this to use JSON
Add more tests
Add more functionality
Parting Thoughts
See the value in your tests now that they are
reusable.
It is annoying at first, but it pays off. Tests like
this have small upkeep, and give you a lot of
freedom to experiment.
I hated TDD at first. Now, I think it's “okay”
Thank you!
TIMOTHY BOLTON

More Related Content

What's hot

ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?
장현 한
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
archana singh
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
Praveen kumar
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Jon Kruger
 
Browser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal EuropeBrowser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal Europe
Salvador Molina (Slv_)
 
Java. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax ApplicationsJava. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax Applications
Марія Русин
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
Jon Kruger
 
How do I write Testable Javascript
How do I write Testable JavascriptHow do I write Testable Javascript
How do I write Testable Javascript
ColdFusionConference
 
How do I write Testable Javascript?
How do I write Testable Javascript?How do I write Testable Javascript?
How do I write Testable Javascript?
Gavin Pickin
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design Principles
Jon Kruger
 
Class-based views with Django
Class-based views with DjangoClass-based views with Django
Class-based views with Django
Simon Willison
 
2016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES62016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES6
양재동 코드랩
 
Odoo - CMS performances optimization
Odoo - CMS performances optimizationOdoo - CMS performances optimization
Odoo - CMS performances optimization
Odoo
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
Antoine Rey
 
От экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшенОт экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшен
Dmitry Makhnev
 
Rails Security
Rails SecurityRails Security
Rails Security
Wen-Tien Chang
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
Naga Muruga
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 

What's hot (19)

ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
 
Browser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal EuropeBrowser testing with nightwatch.js - Drupal Europe
Browser testing with nightwatch.js - Drupal Europe
 
Java. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax ApplicationsJava. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax Applications
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
 
How do I write Testable Javascript
How do I write Testable JavascriptHow do I write Testable Javascript
How do I write Testable Javascript
 
How do I write Testable Javascript?
How do I write Testable Javascript?How do I write Testable Javascript?
How do I write Testable Javascript?
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design Principles
 
Class-based views with Django
Class-based views with DjangoClass-based views with Django
Class-based views with Django
 
2016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES62016 W3C Conference #4 : ANGULAR + ES6
2016 W3C Conference #4 : ANGULAR + ES6
 
Odoo - CMS performances optimization
Odoo - CMS performances optimizationOdoo - CMS performances optimization
Odoo - CMS performances optimization
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
От экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшенОт экспериментов с инфраструктурой до внедрения в продакшен
От экспериментов с инфраструктурой до внедрения в продакшен
 
Rails Security
Rails SecurityRails Security
Rails Security
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 

Similar to Test driven development (java script & mivascript)

Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
Mats Bryntse
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
Sebastian Springer
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
Mats Bryntse
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
Judy Breedlove
 
Testing in Laravel Framework
Testing in Laravel FrameworkTesting in Laravel Framework
Testing in Laravel Framework
Anis Ahmad
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVC
Andy Butland
 
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShellCCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
walk2talk srl
 
Structured Testing Framework
Structured Testing FrameworkStructured Testing Framework
Structured Testing Framework
serzar
 
Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineAdding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
Eduardo Piairo
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
Peter Elst
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
Steven Feuerstein
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
Tobias Trelle
 
Azure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best PracticesAzure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best Practices
Jose Manuel Jurado Diaz
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
Ben Hall
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
tdc-globalcode
 
Introduction to mysql part 3
Introduction to mysql part 3Introduction to mysql part 3
Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
Naresha K
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
Salesforce Developers
 

Similar to Test driven development (java script & mivascript) (20)

Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 
Testing in Laravel Framework
Testing in Laravel FrameworkTesting in Laravel Framework
Testing in Laravel Framework
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVC
 
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShellCCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
CCI2018 - Automatizzare la creazione di risorse con ARM template e PowerShell
 
Structured Testing Framework
Structured Testing FrameworkStructured Testing Framework
Structured Testing Framework
 
Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineAdding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
 
Azure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best PracticesAzure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best Practices
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
Introduction to mysql part 3
Introduction to mysql part 3Introduction to mysql part 3
Introduction to mysql part 3
 
Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
 

More from Miva

2016 Ecommerce Trends & Conversion Best Practices
2016 Ecommerce Trends & Conversion Best Practices2016 Ecommerce Trends & Conversion Best Practices
2016 Ecommerce Trends & Conversion Best Practices
Miva
 
Miva ReadyThemes for Store Owners
Miva ReadyThemes for Store OwnersMiva ReadyThemes for Store Owners
Miva ReadyThemes for Store Owners
Miva
 
Facebook Advertising: From Content to Conversions
Facebook Advertising: From Content to ConversionsFacebook Advertising: From Content to Conversions
Facebook Advertising: From Content to Conversions
Miva
 
Artistry and Ethics in Email Marketing
Artistry and Ethics in Email MarketingArtistry and Ethics in Email Marketing
Artistry and Ethics in Email Marketing
Miva
 
Secrets to Writing Content That Matters - Gillian Muessig
Secrets to Writing Content That Matters - Gillian MuessigSecrets to Writing Content That Matters - Gillian Muessig
Secrets to Writing Content That Matters - Gillian Muessig
Miva
 
Content Marketing Data That Moves the Needle
Content Marketing Data That Moves the NeedleContent Marketing Data That Moves the Needle
Content Marketing Data That Moves the Needle
Miva
 
7 Actionable SEO Strategies to Build Real Revenue Now
7 Actionable SEO Strategies to Build Real Revenue Now7 Actionable SEO Strategies to Build Real Revenue Now
7 Actionable SEO Strategies to Build Real Revenue Now
Miva
 
Wizards & Executors - Gillian Muessig
Wizards & Executors  - Gillian MuessigWizards & Executors  - Gillian Muessig
Wizards & Executors - Gillian Muessig
Miva
 
What's New in Miva Merchant 9
What's New in Miva Merchant 9What's New in Miva Merchant 9
What's New in Miva Merchant 9
Miva
 
Increasing Conversions with Relevancy, Merchandising & Actionable Insights
Increasing Conversions with Relevancy, Merchandising & Actionable InsightsIncreasing Conversions with Relevancy, Merchandising & Actionable Insights
Increasing Conversions with Relevancy, Merchandising & Actionable Insights
Miva
 
Google Analytics for Miva Merchants
Google Analytics for Miva MerchantsGoogle Analytics for Miva Merchants
Google Analytics for Miva Merchants
Miva
 
Expanding Product Sales Using eBay & Amazon
Expanding Product Sales Using eBay & AmazonExpanding Product Sales Using eBay & Amazon
Expanding Product Sales Using eBay & Amazon
Miva
 
Web Development Trends 2016
Web Development Trends 2016Web Development Trends 2016
Web Development Trends 2016
Miva
 
Trust Drives Ecommerce Differentiations & Conversions
Trust Drives Ecommerce Differentiations & ConversionsTrust Drives Ecommerce Differentiations & Conversions
Trust Drives Ecommerce Differentiations & Conversions
Miva
 
Best Practices in Order Fulfillment
Best Practices in Order FulfillmentBest Practices in Order Fulfillment
Best Practices in Order Fulfillment
Miva
 
2016 Mobile Design & UX Trends
2016 Mobile Design & UX Trends2016 Mobile Design & UX Trends
2016 Mobile Design & UX Trends
Miva
 
On Page SEO & Miva Merchant 2016
On Page SEO & Miva Merchant 2016On Page SEO & Miva Merchant 2016
On Page SEO & Miva Merchant 2016
Miva
 
Miva Merchant 9 Admin - Optimizing Daily Workflow
Miva Merchant 9 Admin - Optimizing Daily WorkflowMiva Merchant 9 Admin - Optimizing Daily Workflow
Miva Merchant 9 Admin - Optimizing Daily Workflow
Miva
 
Merchandising & Miva Merchant 9 - Price Groups
Merchandising & Miva Merchant 9 - Price GroupsMerchandising & Miva Merchant 9 - Price Groups
Merchandising & Miva Merchant 9 - Price Groups
Miva
 
Usability & User Engagement
Usability & User EngagementUsability & User Engagement
Usability & User Engagement
Miva
 

More from Miva (20)

2016 Ecommerce Trends & Conversion Best Practices
2016 Ecommerce Trends & Conversion Best Practices2016 Ecommerce Trends & Conversion Best Practices
2016 Ecommerce Trends & Conversion Best Practices
 
Miva ReadyThemes for Store Owners
Miva ReadyThemes for Store OwnersMiva ReadyThemes for Store Owners
Miva ReadyThemes for Store Owners
 
Facebook Advertising: From Content to Conversions
Facebook Advertising: From Content to ConversionsFacebook Advertising: From Content to Conversions
Facebook Advertising: From Content to Conversions
 
Artistry and Ethics in Email Marketing
Artistry and Ethics in Email MarketingArtistry and Ethics in Email Marketing
Artistry and Ethics in Email Marketing
 
Secrets to Writing Content That Matters - Gillian Muessig
Secrets to Writing Content That Matters - Gillian MuessigSecrets to Writing Content That Matters - Gillian Muessig
Secrets to Writing Content That Matters - Gillian Muessig
 
Content Marketing Data That Moves the Needle
Content Marketing Data That Moves the NeedleContent Marketing Data That Moves the Needle
Content Marketing Data That Moves the Needle
 
7 Actionable SEO Strategies to Build Real Revenue Now
7 Actionable SEO Strategies to Build Real Revenue Now7 Actionable SEO Strategies to Build Real Revenue Now
7 Actionable SEO Strategies to Build Real Revenue Now
 
Wizards & Executors - Gillian Muessig
Wizards & Executors  - Gillian MuessigWizards & Executors  - Gillian Muessig
Wizards & Executors - Gillian Muessig
 
What's New in Miva Merchant 9
What's New in Miva Merchant 9What's New in Miva Merchant 9
What's New in Miva Merchant 9
 
Increasing Conversions with Relevancy, Merchandising & Actionable Insights
Increasing Conversions with Relevancy, Merchandising & Actionable InsightsIncreasing Conversions with Relevancy, Merchandising & Actionable Insights
Increasing Conversions with Relevancy, Merchandising & Actionable Insights
 
Google Analytics for Miva Merchants
Google Analytics for Miva MerchantsGoogle Analytics for Miva Merchants
Google Analytics for Miva Merchants
 
Expanding Product Sales Using eBay & Amazon
Expanding Product Sales Using eBay & AmazonExpanding Product Sales Using eBay & Amazon
Expanding Product Sales Using eBay & Amazon
 
Web Development Trends 2016
Web Development Trends 2016Web Development Trends 2016
Web Development Trends 2016
 
Trust Drives Ecommerce Differentiations & Conversions
Trust Drives Ecommerce Differentiations & ConversionsTrust Drives Ecommerce Differentiations & Conversions
Trust Drives Ecommerce Differentiations & Conversions
 
Best Practices in Order Fulfillment
Best Practices in Order FulfillmentBest Practices in Order Fulfillment
Best Practices in Order Fulfillment
 
2016 Mobile Design & UX Trends
2016 Mobile Design & UX Trends2016 Mobile Design & UX Trends
2016 Mobile Design & UX Trends
 
On Page SEO & Miva Merchant 2016
On Page SEO & Miva Merchant 2016On Page SEO & Miva Merchant 2016
On Page SEO & Miva Merchant 2016
 
Miva Merchant 9 Admin - Optimizing Daily Workflow
Miva Merchant 9 Admin - Optimizing Daily WorkflowMiva Merchant 9 Admin - Optimizing Daily Workflow
Miva Merchant 9 Admin - Optimizing Daily Workflow
 
Merchandising & Miva Merchant 9 - Price Groups
Merchandising & Miva Merchant 9 - Price GroupsMerchandising & Miva Merchant 9 - Price Groups
Merchandising & Miva Merchant 9 - Price Groups
 
Usability & User Engagement
Usability & User EngagementUsability & User Engagement
Usability & User Engagement
 

Recently uploaded

Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
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
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
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
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 

Recently uploaded (20)

Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
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
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
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
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 

Test driven development (java script & mivascript)

  • 2. Test Driven Development •What is TDD? •Why use TDD? •How to use TDD? •When to stray from TDD? •Super Simple Sample of TDD •Recap
  • 3. What is TDD? •Development “driven” by testing. –Tests are written before code is. –Tests should initially fail –Production code should be enough to pass •A simple philosophy •A great way to make you feel superior
  • 4. Why use TDD? •It makes refactoring very simple. •It gives you confidence •It helps create a scope of work •It creates a baseline •It helps you document your project •It helps bring new developers up to speed
  • 5. How to use TDD? •There are 3 Rules 1.No production code unless it makes a failing test pass. 2.No more of a unit test written than is sufficient to make it fail. 3.No more production code is written than is sufficient to pass the one failing unit test.
  • 6. How to use TDD cont’d •Build your own tools –My Environment consists of: •Vim •Tmux •watchTests.sh Script •Inotifywait
  • 7. When to stray from TDD? •Ideally, “never” •Realistically? –Working on a pre-existing project –Working in a language where TDD frameworks are not established –When tests take too long. It’s the truth. :’(
  • 8. Super Simple Sample of TDD •Email address availability with pure MivaScript and JavaScript •Remember –We don’t have a lot of time –We won’t write a lot of tests for MivaScript –We don’t have tools built for Mocking •https://bitbucket.org/snippets/timothybolton/BdL8
  • 9. Super Simple Sample Cont’d •Where to start? –MivaScript •Create a simple “AssertTrue” function •Create a simple queryEmailTests.mv file –Put some lipstick on that pig with formatting –Write the first test •Create production code
  • 10. Super Simple Sample Cont’d •What are we trying to accomplish? See if an email address is used already •Moving parts and external dependencies –Database Connection –Data in Database –Network Connection
  • 11. Super Simple Sample Cont’d MivaScript “AssertEqual” function While we certainly don't need a function to do this, as we can make simple assertions with “MvIF” statements, it makes the code easier to read and communicates the intention. Other Assertions AssertTrue, AssertFalse, AssertNull, AssertNotNull AssertNotEqual, AssertIsDigit, AssertIsAlpha, etc. Be creative. Work together. Write better scripts.
  • 12. Super Simple Sample Cont’d FILE NAME: mvassert.mv 1 <MIVA STANDARDOUTPUTLEVEL = "text, compresswhitespace"> 2 <MvFUNCTION NAME = "AssertEqual" PARAMETERS = "expected, actual" STANDARDOUTPUTLEVEL="" ERROROUTPUTLEVEL=""> 3 <MvFUNCTIONRETURN VALUE = "{ l.expected EQ l.actual }"> 4 </MvFUNCTION>
  • 13. Super Simple Sample Cont’d FILE NAME: mvTestLibrary.mv 1 <MIVA STANDARDOUTPUTLEVEL = "html, compresswhitespace"> 2 3 <MvFUNCTION NAME = "generateTestResults" STANDARDOUTPUTLEVEL = "html, compresswhitespace"> 4 <MvEVAL EXPR = "{ buildViewStart() }"> 5 6 <MvFOR INDEX = "l.pos" FIRST = "{ 1 }" NEXT = "{ ++l.pos }" LAST = "{ g.currentTestNumber }"> 7 <MvASSIGN NAME = "l.currentTestStatusStyle" VALUE = "{ generateTestStatusStyle(g.testResults[l.pos]:status) }"> 8 <MvEVAL EXPR = "{ generateTestRowData(g.testResults[l.pos]:name, l.currentTestStatusStyle) }"> 9 </MvFOR> 10 <MvEVAL EXPR = "{ buildViewEnd() }"> 11 </MvFUNCTION> 12 13 <MvFUNCTION NAME = "generateTestRowData" PARAMETERS = "name, style" STANDARDOUTPUTLEVEL = "compresswhitespace"> 14 <MvIF EXPR = "{ g.source EQ 'curlVim' }"> 15 <MvASSIGN NAME = "l.view" VALUE = "{ generateTestRowDataCli(l.name, l.style) }"> 16 <MvELSE> 17 <MvASSIGN NAME = "l.view" VALUE = "{ generateTestRowDataHtml(l.name, l.style) }"> 18 </MvIF> 19 <MvFUNCTIONRETURN VALUE = "{ l.view }"> 20 </MvFUNCTION> 21 22 <MvFUNCTION NAME = "generateTestRowDataHtml" PARAMETERS = "name, style" STANDARDOUTPUTLEVEL = "compresswhitespace"> 23 <MvFUNCTIONRETURN VALUE = "{ '<tr><td>' $ l.style $ '</td><td>' $ l.name $ '()</td></tr>' }"> 24 </MvFUNCTION> 25 26 <MvFUNCTION NAME = "generateTestRowDataCli" PARAMETERS = "name, style" STANDARDOUTPUTLEVEL = "compresswhitespace"> 27 <MvFUNCTIONRETURN VALUE = "{ ' 28 ' $ l.style $ ' ' $ l.name $ '()' }"> 29 </MvFUNCTION> 30 31 <MvFUNCTION NAME = "buildViewEnd"> 32 <MvIF EXPR = "{ g.source EQ 'curlVim' }">
  • 14. Super Simple Sample Cont’d FILENAME:queryEmailTests.mv 1 <MIVA STANDARDOUTPUTLEVEL = "text"> 2 <MvINCLUDE FILE = "mvassert.mv"> 3 <MvINCLUDE FILE = "mvTestLibrary.mv"> 4 <MvINCLUDE FILE = "queryEmailFunctions.mv"> 5 <MvASSIGN NAME = "g.currentTestNumber" VALUE = 0> 7 <MvCOMMENT>Tests are run here</MvCOMMENT> 8 <MvASSIGN NAME = "l.result" VALUE = "{ testEmailAvailableOnAddress() }"> 10 <MvEVAL EXPR = "{ generateTestResults() }"> 11 <MvEXIT> 13 <MvCOMMENT>Tests are written here</MvCOMMENT> 14 <MvFUNCTION NAME = "testEmailAvailableOnAddress" STANDARDOUTPUTLEVEL = "compresswhitespace"> 15 <MvASSIGN NAME = "g.currentTestNumber" VALUE = "{ ++g.currentTestNumber }"> 16 <MvASSIGN NAME = "g.testResults" MEMBER = "status" INDEX = "{ g.currentTestNumber }" VALUE = "{ AssertEqual(1, CheckEmailAvailable('jimmy@jon.net')) }"> 17 <MvASSIGN NAME = "g.testResults" MEMBER = "name" INDEX = "{ g.currentTestNumber }" VALUE = "{ 'testEmailAvailableOnAddress' }"> 18 </MvFUNCTION>
  • 15. Super Simple Sample Cont’d Vim integration (put in your .vimrc, and validate for your sites) nnoremap <Leader>ca :! mvc % && curl -T %c ftp://ftp.mivamerchantdev.com/mm5/5.00/modules/util/ -u bolton.timothy@gmail.com@dts2639.mivamerchantdev.com:$MIVAPASSWORD && clear && curl http://dts2639.mivamerchantdev.com/mm5/5.00/modules/util/%c?Store_Code=MIVA_DEV&source=curlVim<CR>
  • 16. Super Simple Sample Cont’d We have our first test, let's try to run it. What do you think will happen? That's right… it won't work. We need to write our production function.
  • 17. Super Simple Sample Cont’d Boiler Plate Code FILENAME: queryEmailFunctions.mv 1 <MIVA STANDARDOUTPUTLEVEL = "text, compresswhitespace"> 2 <MvCOMMENT> 99% of this code is from the LSK or the fora.</MvCOMMENT> 3 <MvDO FILE = "../../lib/config.mvc"> 4 5 <MvIF EXPR = "{ NOT [ '../../lib/db.mvc' ].OpenDataFiles( g.Merchant_Version, g.Domain ) }"> 6 <MvEXIT> 7 </MvIF> 8 9 <MvEVAL EXPR = "{ [ '../../lib/util.mvc' ].SetRuntimePaths() }"> 10 11 <MvIF EXPR = "{ NOT [ g.Module_Library_DB ].Store_Open( g.Store_Code, g.Store ) }"> 12 <MvIF EXPR = "{ NOT g.Store_Code }"> <MvEVAL EXPR = "{ 'YOU NEED TO SUPPLY g.Store_Code' }"> </MvIF> 13 <MvEXIT> 14 </MvIF>
  • 18. Super Simple Sample Cont’d 16 <MvFUNCTION NAME = "CheckEmailAvailable" PARAMETERS = "email" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = ""> 17 <MvOPENVIEW NAME = "Merchant" 18 VIEW = "Customers" 19 QUERY = "{ 'SELECT COUNT(*) AS emailUsed ' 20 $ 'FROM ' $ g.Store_Table_Prefix $ 'Customers ' 21 $ 'WHERE ' $ [ g.Module_Library_Native_DBAPI ].DB_Compare_UPPER( 'pw_email' ) 22 $ ' = ' 23 $ [ g.Module_Library_Native_DBAPI ].DB_Compare_UPPER( '?' ) }" 24 FIELDS = "l.email"> 25 <MvIF EXPR = "{ Customers.d.emailUsed GT 0 }"> 26 <MvASSIGN NAME = "l.returnValue" VALUE = "0"> 27 <MvELSE> 28 <MvASSIGN NAME = "l.returnValue" VALUE = "1"> 29 </MvIF> 30 <MvCLOSEVIEW NAME = "Merchant" VIEW = "Customers" > 31 <MvFUNCTIONRETURN VALUE = "{l.returnValue }"> 32 </MvFUNCTION>
  • 19. Super Simple Sample Cont’d What happens when we run now? Using our Vim plugin, we can run from within our editor, from the CLI, or via the web. The mvTestFramework has detection from passed in parameters, to see the output we specify.
  • 20. Super Simple Sample Cont’d Separation Separation function declarations from side-effects This make testing easier Our compiled script 1 <MIVA STANDARDOUTPUTLEVEL = "text, compresswhitespace"> 2 <MvINCLUDE FILE="queryEmailFunctions.mv"> 4 <MvEVAL EXPR = "{ CheckEmailAvailable(g.username) }"> 5 <MvEXIT>
  • 21. Super Simple Sample Cont’d Test again. Now we can rinse and repeat with another test.
  • 22. Super Simple Sample Cont’d JavaScript Testing Ajax can be difficult without mocking, or using synchronous calls. Which would then be “Jax”… because, there is no 'A'. This is depreciated because it degrades the user experience, but it can be useful for testing.
  • 23. Super Simple Sample Cont’d Our simple assertion library will leverage some of the console behavior that comes with Chrome and other browsers. We will just create a simple tdd page that we can protect.
  • 24. Super Simple Sample Cont’d 1 var testAjax = new XMLHttpRequest(); 2 3 testAjax.onreadystatechange = function() { 4 if(testAjax.readyState == 4 && testAjax.status == 200) { 5 return parseInt(testAjax.responseText); 6 } 7 } 8 9 function testAvailableEmail(email) { 10 testAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + email, false); 11 testAjax.send(); 12 return { "test": arguments.callee.name, 13 "actual": testAjax.responseText, 14 "expected": 1 15 }; 16 } 17 18 function testUnavailableEmail(email) { 19 testAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + email, false); 20 testAjax.send(); 21 return { "test": arguments.callee.name, 22 "actual": testAjax.responseText, 23 "expected": 0 24 }; 25 } 26 27 var testInformation = new Array(); 28 29 testInformation.push(testAvailableEmail('notused@example.com')); 30 testInformation.push(testUnavailableEmail('bolton.timothy@gmail.com')); 31 32 for(var i = 0; i < testInformation.length; i++) { 33 console.assert(testInformation[i].actual == testInformation[i].expected, testInformation[i].test + ' Failed. ' 34 + 'Actual: ' + testInformation[i].actual + '. Expected: ' + testInformation[i].expected ); 35 }
  • 25. Super Simple Sample Cont’d 17 function testUnavailableEmail(email) { 18 testAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + email, false); 19 testAjax.send(); 20 return { "test": arguments.callee.name, 21 "actual": testAjax.responseText, 22 "expected": 0 }; 23 }
  • 26. Super Simple Sample Cont’d 27 testInformation.push(testAvailableEmail('notused@example.com')); 28 testInformation.push(testUnavailableEmail('bolton.timothy@gmail.com')); 29 30 for(var i = 0; i < testInformation.length; i++) { 31 console.assert(testInformation[i].actual == testInformation[i].expected, 32 testInformation[i].test + ' Failed. ' 33 + 'Actual: ' + testInformation[i].actual + '. Expected: ' + testInformation[i].expected ); 34 }
  • 27. Super Simple Sample Cont’d We are ready to put up some production code now.
  • 28. Super Simple Sample Cont’d 1 var newAjax = new XMLHttpRequest(); 2 3 newAjax.onreadystatechange = function() { 4 if(newAjax.readyState == 4 && newAjax.status == 200) { 5 responseAction(newAjax.responseText); 6 } 7 } 8 9 var email = document.getElementById('Customer_LoginEmail'); 10 11 email.onchange = function() { 12 newAjax.open("GET", "5.00/modules/util/queryEmail.mvc?store_code=MIVA_DEV&username=" + this.value); 13 newAjax.send(); 14 } 15 16 function responseAction(response) { 17 var alertText = ""; 18 if(parseInt(response) == 0) { 19 alertText = "That username is unavailable"; 20 } else { 21 alertText = "that username is available"; 22 } 23 alert(alertText); 24 }
  • 29. Super Simple Sample Cont’d We are ready to put up some production code now. We have successfully test driven developed.
  • 30. Exercises Refactor this to use JSON Add more tests Add more functionality
  • 31. Parting Thoughts See the value in your tests now that they are reusable. It is annoying at first, but it pays off. Tests like this have small upkeep, and give you a lot of freedom to experiment. I hated TDD at first. Now, I think it's “okay”