- Don’t aim at unit testing each method in the SUT. Unit test only the publicly available API.
- When writing unit tests, mimic the behavior of the SUT’s clients.
- Don’t test private methods. Either unit test them indirectly, using the public API, or extract them into separate classes and test those classes instead.
- Don’t hesitate to unit test internal classes as long as you follow the guidelines above
- Test data should kept and read from a file instead of string variable
Wednesday, May 30, 2018
Junit best practice
Tuesday, May 29, 2018
Basic Git commands
Create a new local branch from remote branch:
git checkout <new-branch>
.git checkout -b <new-branch> <existing-branch>
$ git branch -a
* feature/development_0.0.0
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/feature/development_1.0.0
remotes/origin/master
Example : I will checkout the remote branch origin/feature/development_1.0.0 to the new local branch "feature/development_1.0.0"
git checkout -b "feature/development_1.0.0" "origin/feature/development_1.0.0"
Delete a local branch :
Before deleting the branch make sure the branch is not currently checked out.
git branch -d <lOCAL-branch>
Show all the local and remote branch :
git branch -a
Add all the changes:
git add .
Git commit with message :
git commit -m "my commit message"
# Show All tags :
$ git tag
# Git Reset
$git reset --soft "49055cea321e4468e42853e47a4a6fc3bd21134a"
Sunday, May 27, 2018
Load Test Using JMeter
What is JMeter?
JMeter is an software that can be used to execute performance testing, load testing and functional testing of your web applications. JMeter can also simulate a heavy load on a server by creating tons of virtual concurrent users to web server.
Please find more details here
In this test I will show you how we can run a simple API load test using Jmeter:
API on which load test will be run:
http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22
You can find details info here:
1. Open Apache Jmeter
2. Add a new thread group
Configure thread group using following settings:
Number of Thread (user) L:10
Ramp-Up Period: 5
Loop Count = Foreever
Scheduler = true
Duration : 30 second
3. add a new sampler
Configure HTTP Request using following settings:
Server: samples.openweathermap.org
Path : /data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22
4. Add a New Config element
You can add different heads information using HTTP header manager. (not required for this load test)
5. Add a new Listener
6. Execute the test and see the result
Details about different configuration option :
Number of Threads: Number of users to simulate
Ramp-up Period: To initialize the users on to server
Loop Count: Denotes the number of times the user to perform a particular test
Delay Thread creation until needed: Waits until the completion of the time mentioned to create threads
Scheduler :To enable or disable the scheduler
Start Time: Available only after enable of scheduler, used to mention at what point of time the execution need to be started
End Time :Available only after enable of scheduler, used to mention at what point of time the execution need to be stopped
Duration :Available only after enable of scheduler, used to mention how long the execution is to be happened.
Note: If duration time is mentioned, then the end time will be ignored
Note: If duration time is mentioned, then the end time will be ignored
Startup delay :Available only after enable of scheduler, used to choose the startup delay
Monday, April 30, 2018
How To Install and Use Docker on CentOS 7
Prerequisites
- 64-bit CentOS 7
- Non-root user with sudo privileges. A CentOS 7 server set up using Initial Setup Guide for CentOS 7explains how to set this up.
Note: Docker requires a 64-bit version of CentOS 7 as well as a kernel version equal to or greater than 3.10. The default 64-bit CentOS 7 Droplet meets these requirements.
All the commands in this tutorial should be run as a non-root user. If root access is required for the command, it will be preceded by
sudo
. Initial Setup Guide for CentOS 7 explains how to add users and give them sudo access.Install using the repository
Before you install Docker CE for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
SET UP THE REPOSITORY
-
Install required packages.
yum-utils
provides the yum-config-manager
utility, and device-mapper-persistent-data
and lvm2
are required by the devicemapper
storage driver.
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
-
Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
-
Optional: Enable the edge and test repositories. These repositories are included in the
docker.repo
file above but are disabled by default. You can enable them alongside the stable repository.
$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test
You can disable the edge or test repository by running the yum-config-manager
command with the --disable
flag. To re-enable it, use the --enable
flag. The following command disables the edge repository.
$ sudo yum-config-manager --disable docker-ce-edge
Note: Starting with Docker 17.06, stable releases are also pushed to the edge and test repositories.
Install required packages.
yum-utils
provides the yum-config-manager
utility, and device-mapper-persistent-data
and lvm2
are required by the devicemapper
storage driver.$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
Optional: Enable the edge and test repositories. These repositories are included in the
docker.repo
file above but are disabled by default. You can enable them alongside the stable repository.$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test
You can disable the edge or test repository by running the
yum-config-manager
command with the --disable
flag. To re-enable it, use the --enable
flag. The following command disables the edge repository.$ sudo yum-config-manager --disable docker-ce-edge
Note: Starting with Docker 17.06, stable releases are also pushed to the edge and test repositories.
INSTALL DOCKER CE
-
Install the latest version of Docker CE, or go to the next step to install a specific version:
$ sudo yum install docker-ce
If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
, and if so, accept it.
Got multiple Docker repositories?
If you have multiple Docker repositories enabled, installing or updating without specifying a version in the yum install
or yum update
command always installs the highest possible version, which may not be appropriate for your stability needs.
Docker is installed but not started. The docker
group is created, but no users are added to the group.
-
To install a specific version of Docker CE, list the available versions in the repo, then select and install:
a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the .el7
suffix in this example).
b. Install a specific version by its fully qualified package name, which is the package name (docker-ce
) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-
), for example, docker-ce-18.03.0.ce
.
$ sudo yum install docker-ce-<VERSION STRING>
Docker is installed but not started. The docker
group is created, but no users are added to the group.
-
Start Docker.
$ sudo systemctl start docker
-
Verify that
docker
is installed correctly by running the hello-world
image.
$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
Docker CE is installed and running. You need to use sudo
to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.
Install the latest version of Docker CE, or go to the next step to install a specific version:
$ sudo yum install docker-ce
If prompted to accept the GPG key, verify that the fingerprint matches
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
, and if so, accept it.Got multiple Docker repositories?If you have multiple Docker repositories enabled, installing or updating without specifying a version in theyum install
oryum update
command always installs the highest possible version, which may not be appropriate for your stability needs.
Docker is installed but not started. The
docker
group is created, but no users are added to the group.
To install a specific version of Docker CE, list the available versions in the repo, then select and install:
a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the
.el7
suffix in this example).
b. Install a specific version by its fully qualified package name, which is the package name (
docker-ce
) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-
), for example, docker-ce-18.03.0.ce
.$ sudo yum install docker-ce-<VERSION STRING>
Docker is installed but not started. The
docker
group is created, but no users are added to the group.
Start Docker.
$ sudo systemctl start docker
Verify that
docker
is installed correctly by running the hello-world
image.$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
sudo
to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.Accessing your Virtualbox Guest from your Host OS
As a developer you want to ping and access the webserver on your virtual machine. This is a very simple solution to enable the bridge to the guest VM.
Requirements
- VirtualBox (latest version)
- A guest operation system (e.g. Ubuntu)
Setup
- Shut down all running VM's
- Right click on the VM > Change... > Network
- Open Tab: Adapter 1
- Enable the Adapter and select "NAT"
The next step is importand to make it work:
- Open Tab: Adapter 2
- Enable the adapter and select: "Host-only Adapter"
- Select Name: "VirtualBox Host-only Ethernet Adapter"
- Click at "Extended"
- Select the adapter: "Intel PRO/1000 MT Desktop..."
- Select the modus: "Allow all and host"
- Click on "Ok" to save all settings.
Yes, you have to enable two adapters at the same time to make it work. Realy. You need a "NAT" and a "Host-only Adapter".
- Start the VM
- Open the terminal (with Ctrl+Alt+T)
- Enter:
ifconfig
- Now you should see a local IP addresse like:
192.168.56.104
- The IP address is dynamic an can be different on your VM
Test
- Go back into your host machine
- Open the command line:
cmd
- Ping the guest VM with the command:
ping 192.168.56.104
- You should see the ping response
- If you have a webserver installed on the guest VM then open
http://192.168.56.104
in your browser to the hosted website.
What Is API Testing and Why Should We Be Using It?
Many companies are moving toward a microservices model for their software applications. This means that different sections of their application can have separate datastores and separate commands for interacting with that datastore.
Microservices are appealing to software providers because they allow components of the software to be deployed more quickly; while one area of an application is updated, the other areas of the application can continue to function.
We live in a time when users expect software to be ready to use whenever they want it, and the microservices model ensures that an application will not be down for maintenance when a user wants to use it.
Most microservices are using application programming interfaces (APIs), which are a set of commands for how a service can be used. And most APIs are using Representational State Transfer (REST) requests through Hypertext Transfer Protocol (HTTP) to request and send data.
In spite of this fact, many software testers continue to automate their testing with user interface (UI)-based tests that interact directly with the browser. This is largely due to the success of the Selenium suite of tools for test automation, which runs in a web browser.
Selenium has been available for several years, and most software testers are familiar with its use. But the most familiar tool is not always the most appropriate tool to use in test automation.
While some UI testing will always be needed to verify that elements appear on a page and can be interacted with, API tests are much faster and more reliable than UI-based tests. When testing things like adding and removing records from a database, automated UI tests can be time-consuming and repetitive. API tests allow for rapid record manipulation.
Furthermore, API testing allows the tester to find bugs earlier in the development process, often before the UI has been created. And API testing allows the tester to make requests that might not be allowed through the UI, which is crucial for exposing potential security flaws in an application.
Because changes in software happen at such a rapid pace today, it’s important to have tests that provide fast feedback for developers and testers. API tests can fill this need. We’ll describe the fundamentals of API testing, including how REST requests work and how to set up requests and assertions.
Monday, April 23, 2018
Install Maven in CentOS 7
Step 1: Add maven to the yum libraries:
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
Step 2: Install maven using the following command :
sudo yum install apache-maven
Done!
Check if maven installed correctly
mvn -version
Subscribe to:
Posts (Atom)
5 Strategies for Getting More Work Done in Less Time
Summary. You’ve got more to do than could possibly get done with your current work style. You’ve prioritized. You’ve planned. You’ve dele...

-
Sometimes just to get a quick success build you might need to disable/ignore/skip some of the munit test cases. you can do you by double ...
-
Some times you might need to return static response from nginx. for example validating file upload limit error_page 413 @413_x...
-
Install ActiveMQ Step 1: Download Apache Active MQ 5.x.x (5.15.8 Latest Version Up to Feb 2019) Step 2: Install ActiveMQ Run the Active...