SlideShare une entreprise Scribd logo
1  sur  25
© 2014, Conversant, Inc. All rights reserved.
PRESENTED BY
6/1/15
Ultimate Automation - ScalaTest
Software Test Automation on JVM
Platform
lRajesh Thanavarapu
© 2014, Conversant, Inc. All rights reserved.
Software Test Automation
“In software testing, test automation is the use of special software (separate
from the software being tested) to control the execution of
tests and the comparison of actual outcomes
with predicted outcomes.[1] Test automation can automate
some repetitive but necessary tasks in a formalized testing process already
in place, or add additional testing that would be difficult to perform manually.”
- From Wikipedia, the free encyclopedia
© 2014, Conversant, Inc. All rights reserved.
Test Automation Classification
* Code-driven Test Automation
* GUI Test Automation
* API Test Automation <- Topic of discussion
© 2014, Conversant, Inc. All rights reserved.
Ultimate Automation Tool
* Associate Tests with Specs
* Facilitates simplistic Test design
* Provides complete Data abstraction
* Documentation that is up to date
* Allows for easy enhancements
* Provides visibility to all teams – Business,
Prod, Dev, QA & The Management
© 2014, Conversant, Inc. All rights reserved.
Too Many Names
TDD
ATDD
BDD
FDD
DDD
MDD
R2D2
C3PO
© 2014, Conversant, Inc. All rights reserved.
Specification Testing
* One Source - Tests, Specs, Documentation,
Reports
* Everybody wins – Stake holders, Business,
Product, Developers & Testers
© 2014, Conversant, Inc. All rights reserved.
Scala
* Shares the JVM Space
* JIT Compiled and Bytecode
* Supports both OOP & FP
* Higher Order Language
* Aggressive Road map – Java 8
* Complete Maven Integration
* BSD Licensed
© 2014, Conversant, Inc. All rights reserved.
Java => Scala
Improvements: A non-unified type system (primitives vs.
objects), type erasure (polymorphism), and checked
exceptions.
Additions: Functional programming concepts- type
inference, anonymous functions (closures), lazy
initialization etc.
© 2014, Conversant, Inc. All rights reserved.
Scala Is Concise
Java
public class Person
{
private String firstName;
private String lastName;
// Let's not forget the getters and setters OK?
Person(String firstName, String lastName) {
this.firstName=firstName;
this.lastName=lastName;
}
}
Scala
class Person(firstName:String, lastName:String)
© 2014, Conversant, Inc. All rights reserved.
Scala Is Implicit
Java
public class ClassicSingleton {
private static ClassicSingleton instance = null;
protected ClassicSingleton() {
// Exists only to defeat instantiation.
}
public static ClassicSingleton getInstance() {
if(instance == null) {
instance = new ClassicSingleton();
}
return instance;
}
}
Scala
Object ClassicSingleton{
}
© 2014, Conversant, Inc. All rights reserved.
Scala Is True FP
Lambda Expressions
val even = ( x :Int ) => {
X % 2 == 0 }
even(7)
Output: false
Theory
Var res=f(x)
Var res=f(x) + (f(y) + f(z))
Var res=f(x)=f(a) * f(b)
Best Curry(ing) in town...
© 2014, Conversant, Inc. All rights reserved.
Scala better than Java?
Scala will not replace Java, but it truly
Compliments!!
© 2014, Conversant, Inc. All rights reserved.
Big Companies using Scala
© 2014, Conversant, Inc. All rights reserved.
ScalaTest
* API based on Scala – external jar
* Simple and English like DSL
* Traits for everyone (Java 8 mixin)
FeatureSpec
FlatSpec
FunSpec and more...
© 2014, Conversant, Inc. All rights reserved.
Trait FeatureSpec
class SampleClass extends FeatureSpec {
feature("The user can pop an element off the top of the stack") {
scenario("pop is invoked on a non-empty stack") (pending)
scenario("pop is invoked on an empty stack"){
…
}
ignore("pop is invoked on an empty stack") {
…
}
}
}
© 2014, Conversant, Inc. All rights reserved.
Impl. Detailsprotected def feature(description: String)(fun: => Unit) {
try {
registerNestedBranch(Resources.feature(...), fun,...)
}
catch {
case e: exceptions.TestFailedException => throw new exceptions.(...)
...
}
}
protected def scenario(specText: String, testTags: Tag*)(testFun: FixtureParam => Registeration {
engine.registerTest(Resources.scenario(...)
}
protected def ignore(specText: String, testTags: Tag*)(testFun: FixtureParam => Registeration) {
engine.registerIgnoredTest(...)
}
© 2014, Conversant, Inc. All rights reserved.
Trait FunSpec
class SampleClass extends FunSpec {
describe("A Set") {
describe("when empty") {
it("should have size 0") {
assert(Set.empty.size == 0)
}
it("should produce NoSuchElementException when head is invoked") {
intercept[NoSuchElementException] {
Set.empty.head
}
}
}
}
© 2014, Conversant, Inc. All rights reserved.
Trait FlatSpec
class SampleClass extends FlatSpec {
"An empty Set" should "have size 0" in {
assert(Set.empty.size == 0)
}
it should "produce NoSuchElementException when head is invoked" in {
intercept[NoSuchElementException] {
Set.empty.head
}
}
}
© 2014, Conversant, Inc. All rights reserved.
Many Styles to Choose
http://scalatest.org/user_guide
/selecting_a_style
© 2014, Conversant, Inc. All rights reserved.
Test Development
* Define a comprehensive list of test Scenarios
* Initially write all tests as “Pending”
* Incrementally add test code (worker methods)
Language of choice: Scala, Java or Both
* Review test results
* Add more test Scenarios...
© 2014, Conversant, Inc. All rights reserved.
Sample Code
feature("Block user from registering to listed promotion codes") {
scenario("User should be blocked for a listed promo code and listed company") {
var code = blockReg.testPromoBlockCommand(5050, 77)
code should be("22")
}
scenario("User should not be blocked for a unlisted promo code and listed company") {
var code = blockReg.testPromoBlockCommand(5050, 123)
code should not be ("22")
}
scenario("User should not be blocked for a listed promo code and unlisted company") {
var code = blockReg.testPromoBlockCommand(5318, 77)
code should not be ("22")
}
scenario("User should not be blocked for a unlisted promo code and unlisted company") {
var code = blockReg.testPromoBlockCommand(5318, 123)
code should not be ("22")
}
© 2014, Conversant, Inc. All rights reserved.
Scala Runner
$ scala -cp scalatest_2.11-2.2.4.jar org.scalatest.run ExampleSpec
Discovery starting.
Discovery completed in 21 milliseconds.
Run starting. Expected test count is: 2
ExampleSpec:
A Stack
- should pop values in last-in-first-out order
- should throw NoSuchElementException if an empty stack is popped
Run completed in 76 milliseconds.
Total number of tests run: 2
Suites: completed 1, aborted 0
Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
© 2014, Conversant, Inc. All rights reserved.
Reporting
Note: This report is generated by the FREE Scala Plugin of
Intellij
© 2014, Conversant, Inc. All rights reserved.
References / Links
http://www.scala-lang.org/download/
http://scalatest.org/download
http://doc.scalatest.org/2.2.4/index.html#org.scalatest.package
http://www.scala-lang.org/api/current/#package
http://scala-tools.org/mvnsites/maven-scala-plugin/
Downloads
Guides
Plugin
© 2014, Conversant, Inc. All rights reserved.
Q&A
Pls send your questions and comments
to
rthanavarapu@conversantmedia.com

Contenu connexe

Tendances

Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJSPeter Drinnan
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with exampleshadabgilani
 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Jay Friendly
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit TestChiew Carol
 
Selenium using Java
Selenium using JavaSelenium using Java
Selenium using JavaF K
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Sam Becker
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Iakiv Kramarenko
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorJie-Wei Wu
 
Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Abhijeet Vaikar
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor🌱 Dale Spoonemore
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Sumanth Chinthagunta
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with JestMichał Pierzchała
 
Automated Testing in Angular Slides
Automated Testing in Angular SlidesAutomated Testing in Angular Slides
Automated Testing in Angular SlidesJim Lynch
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8nagpalprachi
 
Codeception presentation
Codeception presentationCodeception presentation
Codeception presentationAndrei Burian
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDISven Ruppert
 
Desktop|Embedded Application API JSR
Desktop|Embedded Application API JSRDesktop|Embedded Application API JSR
Desktop|Embedded Application API JSRAndres Almiray
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JSMichael Haberman
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchMats Bryntse
 

Tendances (20)

Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Selenium using Java
Selenium using JavaSelenium using Java
Selenium using Java
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Automated Testing in Angular Slides
Automated Testing in Angular SlidesAutomated Testing in Angular Slides
Automated Testing in Angular Slides
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8
 
Codeception presentation
Codeception presentationCodeception presentation
Codeception presentation
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDI
 
Desktop|Embedded Application API JSR
Desktop|Embedded Application API JSRDesktop|Embedded Application API JSR
Desktop|Embedded Application API JSR
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 

En vedette

Why vREST?
Why vREST?Why vREST?
Why vREST?vrest_io
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBrendan Gregg
 
Algorithmic Music Recommendations at Spotify
Algorithmic Music Recommendations at SpotifyAlgorithmic Music Recommendations at Spotify
Algorithmic Music Recommendations at SpotifyChris Johnson
 
Music Recommendations at Scale with Spark
Music Recommendations at Scale with SparkMusic Recommendations at Scale with Spark
Music Recommendations at Scale with SparkChris Johnson
 
Scala Data Pipelines for Music Recommendations
Scala Data Pipelines for Music RecommendationsScala Data Pipelines for Music Recommendations
Scala Data Pipelines for Music RecommendationsChris Johnson
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 

En vedette (6)

Why vREST?
Why vREST?Why vREST?
Why vREST?
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame Graphs
 
Algorithmic Music Recommendations at Spotify
Algorithmic Music Recommendations at SpotifyAlgorithmic Music Recommendations at Spotify
Algorithmic Music Recommendations at Spotify
 
Music Recommendations at Scale with Spark
Music Recommendations at Scale with SparkMusic Recommendations at Scale with Spark
Music Recommendations at Scale with Spark
 
Scala Data Pipelines for Music Recommendations
Scala Data Pipelines for Music RecommendationsScala Data Pipelines for Music Recommendations
Scala Data Pipelines for Music Recommendations
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 

Similaire à ScalaTest- Automate API Tests in Scala

Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECSreedhar Chowdam
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!Taras Oleksyn
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Paul King
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance TuningMinh Hoang
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-appsVenkata Ramana
 
Java Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languagesJava Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languagesErik Gur
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCFAKHRUN NISHA
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java PlatformSivakumar Thyagarajan
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7Bruno Borges
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...jaxLondonConference
 

Similaire à ScalaTest- Automate API Tests in Scala (20)

Java Notes
Java Notes Java Notes
Java Notes
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!SCULPT! YOUR! TESTS!
SCULPT! YOUR! TESTS!
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps
 
Java Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languagesJava Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languages
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
What is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK TechnologiesWhat is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK Technologies
 
OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7
 
Good Practices On Test Automation
Good Practices On Test AutomationGood Practices On Test Automation
Good Practices On Test Automation
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
 

Dernier

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Dernier (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 

ScalaTest- Automate API Tests in Scala

  • 1. © 2014, Conversant, Inc. All rights reserved. PRESENTED BY 6/1/15 Ultimate Automation - ScalaTest Software Test Automation on JVM Platform lRajesh Thanavarapu
  • 2. © 2014, Conversant, Inc. All rights reserved. Software Test Automation “In software testing, test automation is the use of special software (separate from the software being tested) to control the execution of tests and the comparison of actual outcomes with predicted outcomes.[1] Test automation can automate some repetitive but necessary tasks in a formalized testing process already in place, or add additional testing that would be difficult to perform manually.” - From Wikipedia, the free encyclopedia
  • 3. © 2014, Conversant, Inc. All rights reserved. Test Automation Classification * Code-driven Test Automation * GUI Test Automation * API Test Automation <- Topic of discussion
  • 4. © 2014, Conversant, Inc. All rights reserved. Ultimate Automation Tool * Associate Tests with Specs * Facilitates simplistic Test design * Provides complete Data abstraction * Documentation that is up to date * Allows for easy enhancements * Provides visibility to all teams – Business, Prod, Dev, QA & The Management
  • 5. © 2014, Conversant, Inc. All rights reserved. Too Many Names TDD ATDD BDD FDD DDD MDD R2D2 C3PO
  • 6. © 2014, Conversant, Inc. All rights reserved. Specification Testing * One Source - Tests, Specs, Documentation, Reports * Everybody wins – Stake holders, Business, Product, Developers & Testers
  • 7. © 2014, Conversant, Inc. All rights reserved. Scala * Shares the JVM Space * JIT Compiled and Bytecode * Supports both OOP & FP * Higher Order Language * Aggressive Road map – Java 8 * Complete Maven Integration * BSD Licensed
  • 8. © 2014, Conversant, Inc. All rights reserved. Java => Scala Improvements: A non-unified type system (primitives vs. objects), type erasure (polymorphism), and checked exceptions. Additions: Functional programming concepts- type inference, anonymous functions (closures), lazy initialization etc.
  • 9. © 2014, Conversant, Inc. All rights reserved. Scala Is Concise Java public class Person { private String firstName; private String lastName; // Let's not forget the getters and setters OK? Person(String firstName, String lastName) { this.firstName=firstName; this.lastName=lastName; } } Scala class Person(firstName:String, lastName:String)
  • 10. © 2014, Conversant, Inc. All rights reserved. Scala Is Implicit Java public class ClassicSingleton { private static ClassicSingleton instance = null; protected ClassicSingleton() { // Exists only to defeat instantiation. } public static ClassicSingleton getInstance() { if(instance == null) { instance = new ClassicSingleton(); } return instance; } } Scala Object ClassicSingleton{ }
  • 11. © 2014, Conversant, Inc. All rights reserved. Scala Is True FP Lambda Expressions val even = ( x :Int ) => { X % 2 == 0 } even(7) Output: false Theory Var res=f(x) Var res=f(x) + (f(y) + f(z)) Var res=f(x)=f(a) * f(b) Best Curry(ing) in town...
  • 12. © 2014, Conversant, Inc. All rights reserved. Scala better than Java? Scala will not replace Java, but it truly Compliments!!
  • 13. © 2014, Conversant, Inc. All rights reserved. Big Companies using Scala
  • 14. © 2014, Conversant, Inc. All rights reserved. ScalaTest * API based on Scala – external jar * Simple and English like DSL * Traits for everyone (Java 8 mixin) FeatureSpec FlatSpec FunSpec and more...
  • 15. © 2014, Conversant, Inc. All rights reserved. Trait FeatureSpec class SampleClass extends FeatureSpec { feature("The user can pop an element off the top of the stack") { scenario("pop is invoked on a non-empty stack") (pending) scenario("pop is invoked on an empty stack"){ … } ignore("pop is invoked on an empty stack") { … } } }
  • 16. © 2014, Conversant, Inc. All rights reserved. Impl. Detailsprotected def feature(description: String)(fun: => Unit) { try { registerNestedBranch(Resources.feature(...), fun,...) } catch { case e: exceptions.TestFailedException => throw new exceptions.(...) ... } } protected def scenario(specText: String, testTags: Tag*)(testFun: FixtureParam => Registeration { engine.registerTest(Resources.scenario(...) } protected def ignore(specText: String, testTags: Tag*)(testFun: FixtureParam => Registeration) { engine.registerIgnoredTest(...) }
  • 17. © 2014, Conversant, Inc. All rights reserved. Trait FunSpec class SampleClass extends FunSpec { describe("A Set") { describe("when empty") { it("should have size 0") { assert(Set.empty.size == 0) } it("should produce NoSuchElementException when head is invoked") { intercept[NoSuchElementException] { Set.empty.head } } } }
  • 18. © 2014, Conversant, Inc. All rights reserved. Trait FlatSpec class SampleClass extends FlatSpec { "An empty Set" should "have size 0" in { assert(Set.empty.size == 0) } it should "produce NoSuchElementException when head is invoked" in { intercept[NoSuchElementException] { Set.empty.head } } }
  • 19. © 2014, Conversant, Inc. All rights reserved. Many Styles to Choose http://scalatest.org/user_guide /selecting_a_style
  • 20. © 2014, Conversant, Inc. All rights reserved. Test Development * Define a comprehensive list of test Scenarios * Initially write all tests as “Pending” * Incrementally add test code (worker methods) Language of choice: Scala, Java or Both * Review test results * Add more test Scenarios...
  • 21. © 2014, Conversant, Inc. All rights reserved. Sample Code feature("Block user from registering to listed promotion codes") { scenario("User should be blocked for a listed promo code and listed company") { var code = blockReg.testPromoBlockCommand(5050, 77) code should be("22") } scenario("User should not be blocked for a unlisted promo code and listed company") { var code = blockReg.testPromoBlockCommand(5050, 123) code should not be ("22") } scenario("User should not be blocked for a listed promo code and unlisted company") { var code = blockReg.testPromoBlockCommand(5318, 77) code should not be ("22") } scenario("User should not be blocked for a unlisted promo code and unlisted company") { var code = blockReg.testPromoBlockCommand(5318, 123) code should not be ("22") }
  • 22. © 2014, Conversant, Inc. All rights reserved. Scala Runner $ scala -cp scalatest_2.11-2.2.4.jar org.scalatest.run ExampleSpec Discovery starting. Discovery completed in 21 milliseconds. Run starting. Expected test count is: 2 ExampleSpec: A Stack - should pop values in last-in-first-out order - should throw NoSuchElementException if an empty stack is popped Run completed in 76 milliseconds. Total number of tests run: 2 Suites: completed 1, aborted 0 Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0 All tests passed.
  • 23. © 2014, Conversant, Inc. All rights reserved. Reporting Note: This report is generated by the FREE Scala Plugin of Intellij
  • 24. © 2014, Conversant, Inc. All rights reserved. References / Links http://www.scala-lang.org/download/ http://scalatest.org/download http://doc.scalatest.org/2.2.4/index.html#org.scalatest.package http://www.scala-lang.org/api/current/#package http://scala-tools.org/mvnsites/maven-scala-plugin/ Downloads Guides Plugin
  • 25. © 2014, Conversant, Inc. All rights reserved. Q&A Pls send your questions and comments to rthanavarapu@conversantmedia.com