Sunday, December 2, 2018

JavaScript Testing

  • How do you test your web app?

  • -Record/Replay
    -Scripting
    -Scripting Page Objects

    Record/Replay
    -Record a test script as you use your application
    -Many tools support this approach
    Selenium IDE
    Commercial tools
    -Pros and cons of Record/Replay
    Intuitive
    Easy to create a test script
    Don’t have to know much about the web application
    Test scripts usually need rework
    Test scripts are fragile
    Test scripts hard to maintain
    Hard to do more complex testing (e.g. data-driven tests)
    Hard to reuse test logic

    Scripting
    -Write a test script using a low-level testing library
    Selenium RC
    HTMLUnit
    -Pros and cons of Scripting
    More powerful tests
    Can do data-driven tests
    Can reuse some test logic
    Higher learning curve
    Need good knowledge of the application
    Test scripts still quite hard to maintain

    Page Objects
    -Create a domain model of your application
    -Hide technical details inside the domain model
    -High level tests written using a different language:
    Programming language (Java,...)
    Scripting language (Groovy, Ruby,...)
    BDD/ATDD framework (easybjbehave,...)
    -Pros and cons of Page Objects
    Much more powerful tests
    Can do data-driven tests
    Easy to reuse test logic
    Tests are easier to maintain
    Tests are understandable by testers
    More up-front thought and design required


    Selenium 2/WebDriver
    Next-Generation version of Selenium
    Build-in support for Page Objects
    One API - Many Drivers
    WebDriver supports several drivers:
    HTMLUnit
    Firefox
    Chrome
    InternetExplorer
    The RemoteWebDriver
    The AndroidDriver
    The iPhoneDriver

    automated-web-testing.pdf




  • build automation


    build scripting
    ant,maven,gradle,gant
    automated code quality
    emma,findbugs
    automated testing
    junit


    The Maven Release Cycle
    -Deploying a release involves many tasks
    -Commit all current changes to version control
    -Upgrade the version number(s) and commit the changes
    -Tag the release version
    -Build and deploy this version
    -Update the version number and commit the changes
    -The Maven Release Plugin automates this process
    Automates the release process
    Updates version numbers
    Commits changes and creates new SCM tags
    Builds, tests and deploys to the Enterprise Repository


    Using the Maven Release Plugin
    mvn release:prepare
    -Audits your code
    Check that there is no uncommitted code
    Check that there are no snapshot dependencies
    Prompts for release tag, branch and new version numbers
    -then does the bookkeeping
    Updates version numbers to release versions
    Creates a new release tag in SCM
    Updates version numbers to next SNAPSHOT versions
    Commit these changes to SCM
    -By default, Maven will prompt you for:
    Release version number
    Release tag
    Next snapshot version number
    -This is not appropriate for automated builds
    mvn release:prepare -B
    -Use batch mode to use sensible default values
    mvn release:perform
    -Do the real work
    Checkout a release version
    Build, test and deploy to the Enterprise repository(archiva,nexus,artifactory etc)
    -Don’t use the maven-release-plugin on your own machine
    -Run it on a build server instea


    Automating the deployment process
    -Don’t rebuild, reuse
    Download application binaries from the Enterprise repository(archiva,nexus,artifactory etc)
    Externalize con?guration as much as possible
    Patch if necessary with target environment con?guration
    Deploy to target environment


    Deployment strategies
    - direct reuse
    - patching


    Deployment strategies - direct reuse
    Reuse from the repository without modi?cation
    Externalized environment-speci?c con?guration
    JNDI
    Local environment-speci?c properties ?les

    Deployment strategies - patching
    Reuse binaries from the repository
    Modify internal con?guration ?les for the target environment
    Can use overlays in Maven



    Automated web deployment with Cargo
    Start, stop and install application servers
    Deploy to different application servers
    Run a stand-alone instance
    Or deploy to an existing server


    Deploying to an embedded Jetty instance
    The simplest way to use Cargo with Maven

    Deploying to a “real” application server
    Deploy to a locally installed instance
    Download and install a server as required
    Deploy to a running server
    Start and stop a server





    Automated web testing
    -Many strategies:
    Run tests before deployment
    Run tests against the deployed application
    -Basic principle - don’t rebuild, deploy
    -Create a special Maven project to run your web tests


    Testing Snapshots or Release Candidates - an approach
    -Use a dedicated release candidate branch
    Changes are merged into the release candidate branches when ready
    Automated tests are (also) run against the release candidate branch
    Releases are run against the release candidate branch
    Updated version numbers need to be merged back to the trunk
    Use multiple repositories on your Enterprise repository(archiva,nexus,artifactory etc)



    automated_deployment.pdf





  • This project demonstrates the basic protractor-cucumber-typescript framework project setup. 

e2e kickstarter test framework which consists of protractor, cucumber frameworks using typescript lang!
https://github.com/igniteram/protractor-cucumber-typescript


  • Delightful JavaScript Testing

Jest is used by Facebook to test all JavaScript code including React applications. One of Jest's philosophies is to provide an integrated "zero-configuration" experience. We observed that when engineers are provided with ready-to-use tools, they end up writing more tests, which in turn results in more stable and healthy code bases.
https://jestjs.io/


  • Front-end

Using jest and enzyme to tests if components are rendered normally.
https://github.com/alpaca0984/QuizMaster

  • spec is a full-featured testing framework that will let you write what Rails considers unit tests, functional tests, and integration tests. All of these exercise Ruby code through various layers of your Rails application. All of these tests simulate requests to your Rails application, but don't actually run the application end-to-end over the network.


cucumber is a browser based integration testing framework, which allows writing automated tests that run against the entire Rails application accessed from within an automated web browser. This allows you to write automated tests about in-browser behavior for JS or CSS. Cucumber provides a unique angle on integration testing that uses plain english specification mapped to code via regular expressions. This allows a more natural "Behavior Driven Development" model - describing what a web application should do, in plain language, from the perspective of the user.

capybara is a particular web driver powering the cucumber integration testing framework, that uses headless webkit. This allows running a headless (without UI) Chrome/Webkit browser for automated testing. This is very useful both in development, but especially on a remote test/continuous integration server.
https://stackoverflow.com/questions/22491145/difference-between-rspec-capybara-and-cucumber


2 comments:

  1. This blog will help to get more ideas. This is very helpful for Software Testing learners. Thank you for sharing this wonderful site. If someone wants to know about Software QA services this is the right place for you Software QA Companies.

    ReplyDelete