Cypress with Galen Study Project

Hello peeps,

Today I am going to post a study project that I have created to try Cypress and Galen. As some of you know Cypress doesn’t support cross browser testing at the moment. This is because the creators believe that nowadays you don’t really need to do functional tests on all the browsers, so what they suggest is to create an automation project for the functionality and run on only one browser and then create another project to run the layout tests on the other browsers.

I kind agree with this statement, since most of the bugs that I have found in my latest projects are layout bugs and doesn’t affect the funcionality of the feature. I say most of the bugs, because I can remember one or two situations where the layout issue affected the functionality. Eg.: Imagine there is a menu that shows a list of options when the mouse is over it. You could have an issue with the css, where this list is overridden by a div and the options are not displayed and clickable.

To give it a go on this idea, I have created a project doing functional tests with Cypress and layout tests with Galen.

The link to the project is here: https://github.com/rafaelaazevedo/bug-free-garbanzo

As always feel free to fork and improve the code, share ideas, fix bugs, etc…

I am still fixing the Docker image to integrate the Cypress and the Galen tests in the same container. For now you can run the tests in the Cypress docker container.

See you next time 🙂

How to Develop a Growth Mindset in Tech

I should have posted this ages ago when I went to the Growth Mindset workshop, but I was on holidays so I had to postpone it a bit. Growth mindset is how you approach failures and challenges in your life. I am going to focus on how to have this mindset in your workplace.

 

 

Have you ever found yourself in your comfort zone ?

 

If you are in your comfort zone you will be for some time until something happens.

Most of people love to be in the comfort zone, it is a safe place right ? But it is not in this zone that you have the chance to improve and be the best version of yourself. I started in the QA area as a manual tester as most of the QAs start and if I didn’t challenge myself I would still be there, doing the same job, unhappy but safe.

When you don’t push yourself to get out of this zone, you will need to wait until you are forced to get out. In these moments you will find yourself defeated because something happened out of your control. Sometimes if you have been in this place for many years you won’t even know where to start. I saw people working +10 years in the same company and when there was a cut they couldn’t find a job after more than 2 years and why is that ? I get that you are comfortable where you are, you have a good salary, quality of life, but and if you are outdated with the current market ? Do you think is really a good idea be completely dependent of a job ? Not sure if it is a good idea, for this reason I prefer not to wait for these moments and create myself new challenges.

 

How do you react a feedback ?

 

Embrace the challenges and be persistent, maybe will take more time than what you expected, but when you reach your objective you will feel fulfilled. There are some feedbacks that depending from who is coming you can ignore, because they are not there to add anything, these are called destructive feedbacks.

These feedbacks could be given by managers who don’t really know your work, they are not working with you daily or they don’t communicate with the team. This makes really hard for a person to give a realistic feedback, so in this case you can completely ignore because clearly this person has no clue of what you do.

They will give you a superficial feedback like you need to communicate more or have lunch with the team more often. Remember that social gathering is optional and you should do only if you feel comfortable enough. Don’t push yourself to go to places with people that you don’t trust or don’t add anything just for networking. It is better spending your time creating a quality network in another place instead.

This problem usually happens when the manager doesn’t know how to build bridges across the team, otherwise socializing in the workplace wouldn’t be a problem in the first place. During these 10 years of experience, I’ve had only 2 good managers which who I still have contact and they became my friends outside work.

The constructive feedbacks should be embraced, they come from these kind of managers. They really care about your development and your growth. They do regular catch ups (doesn’t need to be formal or even announced) with the team and they know how to build a trustworthy relationship.

Keep your mind open for these feedbacks, don’t take it personal and don’t be upset about it. I know we have a constant fight with our ego, but these feedbacks are the steps for your own development. Be thankful for having managers like this that can see yourself under the superficial impression and can give you a good feedback. My suggestion is to keep these kind of people always around, surround yourself with good professionals and be inspired by them.

 

Vision and values: Does the company has the same values as you ? Do you agree with the vision of the company ? Does the company has a vision ? Do you feel included in the company’s vision ?

Money: Do you know your value in the market ? If you don’t, are you doing some interviews to figure out ? Do you have goals where you need to sacrifice your work/life balance for an amount of time ? Is your company valuing you enough increasing your salary ?

Experience: Look for companies that look for generalist developers this means that the company will always follow the new technologies and you won’t be outdated.

Managers & Exec team: Do you trust in your manager ? Do they have your back and fight for the team ? Does he care about your happiness in the work ? Does he take your opinions into account or just ignore them ?

Peers & team: Are you respected in your team ? Do you trust in your team ? Do you have a good sense of collaboration across everybody ?

Work/Life & respect: Do you have a flexible work that understand your needs ? What is the police to work from home ? Do you need to feel the stress of commuting ?

Growth and empowerment: Can you learn from the people that you work with ? Are you growing ? Are you stuck doing the same thing over and over ?

 

How emotionally intelligent are you ?

 

 

Constant Learning

 

To summarize basically what was being written here, push yourself and accept the challenges. You won’t be successful on all of them, but be resilient and continue improving. Take advantage of learning with the previous mistakes. Sometimes you will need to change your strategy or even your goal, but what matters is the quality of the journey !

 

Thanks Joanna Chwastowska for sharing this workshop !

Using Artificial Intelligence to Speed up your Test Automation

Hey guys, today I am going to share with you this awesome webinar that I watched last weekend ! I suggest to follow IIST as they are always sharing good webinars about test.

 

Blockchain Testing Tools

If you are wondering what Blockchain is, I will give you a quick introduction. Blockchain is a data structure that is distributed at once in many different places and as you can’t ever delete from it, it is extremely difficult to make amendments. This makes the record more secure and more trustworthy.

So, what are the kinds of test that you can perform ? You can use the traditional testing, since it is just normal development work with normal testing criteria. So, boundary value analysis, decision tables, test driven development and behavior driven development techniques.

There is also a set of questions that can help you to build your test scenarios, for example:

  • How does it handles valid and invalid inputs?
  • How does it cope with a wide range of input data?
  • How does it handle missing state, or existing state?
  • How does it handle error cases?
  • How does it handle security and access control?

You don’t need to test the Blockchain because the algorithms are well-established, because it is a distributed system, but the transactions still require some kind of validation. For example, you may need to check if your transaction is valid before it can be approved. There are approval authorities for different blockchains, and they must test the integrity of the transactions.

 

What is Smart Contract ?

Smart Contract is an API and defines the rules for transactions in a Blockchain network. A Smart Contract is a set of rules in the form of programmable constructs that are capable of automatically enforcing themselves when pre-defined conditions are met.

It has public functions which might be called by anyone registered on the Blockchain network. However, unlike a traditional API, a Smart Contract cannot call external web APIs.

 

What do you need to know to test Ethereum Smart Contracts ?

Test automation requires that the platform being tested must have hooks so that external automated scripts can instruct the platform, observe the outcome, and verify that the outcome is what is expected. Legacy platforms in banking often do not have these hooks, and that makes automation much more difficult. When you compare smart contracts to older software used in banks, you can automate testing much earlier and much faster.

 

I will show some of the tools that you can use to perform tests on Blockchain applications:

 

Ethereum Tester

This github has a project for you to test Ethereum Blockchain Applications. You will need to clone Eth-Tester. The Eth-tester library strictly enforces some input formats and types.

 

Truffle

Truffle is one of the most popular Ethereum development frameworks and has testing functionality, it is a scaffolding framework for smart contracts used by UI builders. You have the ability to write automated tests for your contracts in both JavaScript and Solidity and get your contracts developed quickly.

Ganache

Ganache is the most-used library for testing Ethereum contracts locally. It mocks a blockchain that gives you access to accounts you can run tests, execute commands, etc.

 

Populus

By default tests run against an in-memory ethereum blockchain and as you can see here Populus supports writing contracts that are specifically for testing.

 

Manticore

Manticore is a symbolic execution tool for analysis of binaries and smart contracts. It is supported on Linux and requires Python 2.7. Ubuntu 16.04 is strongly recommended. It has a Python programming interface which can be used to implement custom analyses. You can see more about here on the wiki.

 

Hyperledger Composer

Hyperledger Composer supports three types of testing: interactive testing, automated unit testing and automated system testing. It’s a framework for rapidly building Blockchain business networks on top of a Blockchain platform, such as Hyperledger Fabric.

This framework allows you to automatically deploy the business network definition, and then interact with it by submitting queries and transactions in order to test how that business network really behaves.

 

Corda Testing Tools

Corda is a blockchain-inspired, open-source distributed ledger platform. There are several distinct test suites each with a different purpose: Unit tests, Integration tests, Smoke tests, Load tests and other. These tests are mostly written with JUnit and can run via Gradle.

 

BitcoinJ

This tool BitcoinJ allows you to interact with Bitcoin connecting directly to the bitcoin network. So, you can simulate send and receive transactions in real time, also you don’t need to have a local copy of the Bitcoin Core.

You can follow this guide to get start with this tool.

 

Resources:

https://www.joecolantonio.com/2018/02/01/blockchain-testing-tools/

https://joecolantonio.com/testtalks/175-blockchain-application-testing-rhian-lewis/

http://searchsoftwarequality.techtarget.com/answer/Heres-everything-you-need-to-know-about-testing-blockchain

https://www.capgemini.com/2017/01/testing-of-smart-contracts-in-the-blockchain-world/

http://www.bcs.org/content/conWebDoc/56020

https://medium.com/@mrsimonstone/test-your-blockchain-business-network-using-hyperledger-composer-c8e8f112da08

WebDriverIO framework first steps

Hey guys, I have been studying a framework called WebdriverIO, it is a really good framework for Angular applications. It is compatible with BDD and TDD, so you can create your features, implement the step definition and it is also a synchronous command handling !!

Not only the hooks, but many useful parts are already in the config file, so you don’t need to create them separately, which is  always very handful.

I have pushed the project to github so you can have a look on my example, it is very simple for now.

https://github.com/rafaelaazevedo/webdriverio-study

 

– To run the project you need to run npm install and after ./node_modules/.bin/wdio wdio.conf.js

 

– In the login-spec.js you can add the scenario (describe) and the steps (it) directly like the step definitions, I don’t have the feature files for now.

– Look how you don’t need to add return for each step anymore. Since the steps are sync you don’t need to worry about it.

– The login-page.js groups all the common functions that will be used on the login scenarios.

– And the login-elements.js contains all the element getters that are on the login page, it works like a library for the elements and it will help you with the maintenance of the code.

If you want to give it a try as well you can add the webdriverio in the package of your project and follow these steps

Run Postman scripts on Jenkins with Docker

You can run Postman scripts from the command line with Newman, but if you want to run these scripts as part of your Continuous Integration environment, you can run it with Docker or directly on Jenkins.  In case you prefer to use Docker, you can get started by downloading the Jenkins Docker instance and changing the Dockerfile to include node using the following node installation code found in the Docker/Jenkins Repository:

# Install Node

RUN curl -sL https://deb.nodesource.com/setup_4.x | bash

RUN apt-get -y install nodejs

RUN node -v

RUN npm -v

RUN npm install -g newman

Then, you will need to rebuild the Docker image and start the container with the same instructions as in the Jenkins Docker Repository.

You should now have a fully working Jenkins instance installed locally. Great! Now back to the task at hand using the newly-installed instance of Jenkins:

  • Create a new “Freestyle” job in Jenkins.

You will set it up to be able to upload the collection as a parameter. When you do this with your own projects, you should commit the Postman collection into whatever repository you’re using and pull directly from that repository to build by selecting “this project is parametrized” and then choosing “Add Parameter” with a “File Parameter.”

 

  • Select two file uploads – one for the collection and one for the environment.

  • Add a post-build step with “Execute Shell”. You’ll use the same command you used to run it from your own command line earlier (If you are using the same OS) except your path should be collection.js, as you named it ‘newman run collection.json’ in the File Parameter name field.

 

  • Now test it and run the build. I just uploaded the collection.json since I’m not using the environment file yet, but you can add it to the command line with:
    newman run collection.json –e environment.json

 

If you want to use the built in JUnit Jenkins viewer, you can archive the XML test result and point the tests to it. Below there is a sample of how you might archive and use the JUnit test results.

Screen Shot 2018-09-01 at 07.30.50Screen Shot 2018-09-01 at 07.30.40

 

 

Resources: https://www.qasymphony.com/blog/automated-api-testing-tutorial/

API tests with newman and postman

 

API is the most important part of your software because it has the highest security risks. What if someone were to hack your API? They could get production data, they could Bitcoin ransom the servers or they could hide on the machine until something interesting happens. The bottom line is, the stakes when using an API are much higher than if there is just a bug in the UI of your application — your data could be at risk and, by proxy, all of your users’ data.

API testing is not only the most vital testing to be done against your application, but it is also the easiest and quickest to execute

With your API tests and having a Continuous integration process, you can:

  • Test all of your endpoints no matter where they are hosted
  • Quickly ensure all of your services are running as expected
  • Confirm that all of your endpoints are secured from unauthorized AND unauthenticated users

 

Postman

Download postman for free

Now you need to have an API to test, you can select one from any-api or qa-symphony for this tutorial. In this example we are going to use this Oxford Dictionaries. Now on postman, you can create a collection and start to feed with your tests. Also, you can create an environment with environment variables and also global variables that can be used across the requests, for example a token.

 

Login with Token on Postman

  • Click on Manage Environments

 

  • Set the host

  • Type the request URL, change the host to the variable {{host}}
  • Select POST request and type the headers

 

  • Type the Body with the credentials for your site.

 

  • Open the Tests tab and write the tests to validate the request and set the access_token as an environment variable. You will need to use this variable in the header of all of your next requests.

var jsonData = JSON.parse(responseBody);

tests["Status code is 200"] = responseCode.code === 200;
tests["Access Token is not blank"] = jsonData.access_token !== "";
tests["Message success"] = jsonData.scope.indexOf("success") !== -1;

postman.setEnvironmentVariable ("access_token", jsonData.access_token);

 

  • Hit Send and if the status code is 200, it means the credentials are correct. Save the request in your collection.

 

  • Now you can create all the other requests and tests needed, just remember to add the {{access_token}} in your header and save the requests in your collection

 

 

Running your API automated tests

  • Now that you have a collection with all your tests, click on Runner and select your collection, environment. Type the number of interactions and delays in case you want to simulate more than multiple interactions.

  • You can also import a CSV file with data and substitute for variables in the body or header of the request.

 

  • The results report will be like this one:

 

Newman

 

To run your tests from the command line you need to have Newman, open your terminal and run npm install -g newman

  • Export your collection from Postman (Collection_v2) and download your environment (go to “Manage Environments” and click the download button) from Postman

 

  • Open your terminal an type the command to run the API tests: newman run /local/path_to_your_postman_collection.json

 

  • The result will be something like this:

 

  • To run the script on Jenkins you need to add the parameters  –reporters junit,json and the results should be created under a folder called “Newman” in your working directory, so: newman run -reporters junit,json /local/path_to_your_postman_collection.json

 

Resources: https://www.qasymphony.com/blog/automated-api-testing-tutorial/

https://api.qasymphony.com/#/login/postAccessToken