SQL

SQL stands for Structured Query Language and is used to communicate with databases. It can be used for storing, manipulating and retrieving data in databases.

A database is basically just a collection of data. A database usually contains one or more tables with columns and rows.

 

Some of The Most Important SQL Commands:

  • SELECT – extracts data from a database
  • UPDATE – updates data in a database
  • DELETE – deletes data from a database
  • INSERT INTO – inserts new data into a database
  • CREATE DATABASE – creates a new database
  • ALTER DATABASE – modifies a database
  • CREATE TABLE – creates a new table
  • ALTER TABLE – modifies a table
  • DROP TABLE – deletes a table
  • CREATE INDEX – creates an index (search key)
  • DROP INDEX – deletes an index

 

Here is a very good website to help you learn more about SQL: https://www.w3schools.com/sql/default.asp

Also, here is a link to a Youtube video that helped me: https://www.youtube.com/watch?v=7S_tz1z_5bA

Testing Types and Techniques

There are many different types of testing and ways to test. Firstly, let me explain Static testing and Dynamic testing:
– During Static testing, the code isn’t executed and it is done using the software documentation. The main objective of Static testing is to improve the quality by finding bugs in the early stages of the development cycle. Examples of Static testing would be reviews, static analysis, etc.
– To perform Dynamic testing, the code needs to be in an executable form and it basically checks the functional behaviour of the software system. The main objective in Dynamic testing is to confirm that the software works in conformance with the business requirements.

Under Dynamic, we would find White Box and Black Box testing.
– White Box testing is a strategy based on internal paths and code structures. It is also known as Structural testing. Some examples are Statement Coverage and Branch Coverage.
– Black box testing is a strategy based on requirements and specification and is usually done to check the functionality of an application.

Black Box testing is classified into two types: Functional testing and Non-Functional testing.
Functional Testing is a type of testing which verifies that each function of the software application conforms with all requirements. It basically describes what the product does. Some examples include Unit testing, Smoke testing, Integration testing, Regression testing, etc. Some techniques that can be used are Equivalence Partitioning, Boundary Value Analysis, etc.
Non-Functional testing is a type of testing done to check aspects like performance, usability, etc. It basically describes how the product works. Some examples of Non-Functional testing are Performance testing, Load testing, Stress testing, Compliance testing, Portability testing, etc.

Here is a diagram I created to get an idea of how they all fit together:

How To Install/Set Up Protractor

Step 1: I downloaded Visual Studio Code to use as my source code editor

 

Step 2: I downloaded Node.js

  • You can download this from the Node.js website, “https://nodejs.org/en/download/
  • In case you don’t know what Node.js is: Node.js is an open-source, cross platform JavaScript run-time environment that executes JavaScript code outside of a browser. “

 

Step 3: Create a folder on your desktop called “Project” (or whichever name you choose)

 

Step 4: Open Visual Studio Code, click on File, click on Open and double click on the folder that you created on your desktop (“Project”)

 

Step 5: A welcome message will appear on Visual Studio Code, click “New File” under “Start” heading

 

Step 6: Open your terminal in Visual Studio Code

 

Step 7: In your terminal, type “npm init” and press enter – (this creates json package)

 

Step 8: You can fill out the details it requires (package name, version, description, entry point, test command, git repository, keywords, author, licence) – you do not have to fill out everything.  After you have filled out details, it will ask “Is this OK?”, click enter to say yes.

 

Step 9: Type “npm install” – (this installs all modules listed as dependencies in json package)

  • You should see two json package files appearing under Projects (“package-lock.json” and “package.json”)

 

Step 10: Type “sudo -i”  – (sudo lets you run commands in your own user account with root privileges)

  • if you have a password for your PC, you will have to type that in and press enter

 

Step 11: Type “npm install -g protractor” and press enter – (this will install Protractor and Webdriver-Manager)

 

Step 12: Type “npm install typescript” and press enter to install TypeScript

 

Step 13: Type “webdriver-manager update” and press enter

 

Step 14: Type “webdriver-manager start” and press enter

 

You would need to do Step 13 and Step 14 every time you start your PC (to update and start webdriver). Also, don’t forget to create a .conf file and a .spec file to run your protractor tests. You use “Protractor conf.js” in your terminal to run your tests. Look at the Protractor website to see how to create and run your first test, https://www.protractortest.org/#/tutorial, this website will be very helpful as a starting point 🙂 

The Role of the Tester

Last week, I started reading a book called “Lessons Learned in Software Testing: A Context-Driven Approach”. It gives lessons in each chapter that I think will help any software tester in their testing journey. Chapter 1 is called “The Role of the Tester” and it addresses what testers are supposed to do for a project.

 

Lesson 1: You are the headlights of the Project

  • Some projects are easy and simple, like driving during the day, but most projects are tough, and it may be more like driving a truck, off road, at night. This paints a pretty good picture about how different projects can be. As the tester, the book mentioned that you light the way, almost like a light shining on the road ahead so that the team can see where they are, what is ahead and how close they are driving to the edge. Testing is done to find information, and critical decisions get made from that information. SO remember, you are the light 🙂 

 

Lesson 2: Your mission drives everything you do

  • Find out what is expected to you and have a clear mission

    Some examples may be to:

  • Find important bugs fast
  • Provide a general assessment of the quality of the product
  • Make sure that the product meets a certain standard
  • Improve product quality
  • Follow a certain set of methods or rules
  • Help your clients improve their processes
  • Do whatever is necessary to satisfy particular clients
  • Etc.

 

Lesson 3: You serve many clients

  • Testing is a service role and you need to remember that the service you provide is very important.

 

Lesson 4: You discover things that will “bug” someone whose opinion matters

  • As a tester, it is your duty to report your concerns, if the client does not listen, it is their choice.

 

Lesson 5: Find important bugs fast

  • Test things that have been changed first
  • Test core functions first
  • Test capability before reliability
  • Test common situations before testing situations unlikely situations
  • Know the product you are testing and also know the people who are going to be using it

 

Lesson 6: Run with the programmers

  • Support the programmers and give them feedback as soon as possible

 

Lesson 7: Question everything, but not necessarily out loud

  • To test well, you need to question
  • If you find yourself testing and you have no questions, take a break

 

Lesson 8: You focus on failure, so your clients can focus on success

  • Testing is the only role that does not directly focus on success (it can be seen as negative)
  • Testers focus on failure because it improves their chances of finding it. Look for key problems in the product with all your creativity and skill. If you don’t find them, they can’t be fixed, and then the users may find them for you. By finding what’s there to find in the product, you help the project team learn more about their own skills and the product’s risks, and you help them make the product better, more supportable, and probably more successful in the marketplace.”Chapter 1 of “Lessons Learned in Software Testing: A Context-Driven Approach”

 

Lesson 9: You will not find all the bugs

  • It is not possible to find every bug

 

Lesson 10: Beware of testing completely

  • “Complete” testing can mean many things (make sure you clarify what “complete” or “done” means)

 

Lesson 11: You don’t assure quality by testing

  • Testers don’t break the product; it was already broken. Quality comes from the people who created the product, but that is a heavy burden to bear so we help deal with the burden more effectively (it is a team effort)

 

Lesson 12: Never be the gatekeeper

  • Don’t be completely in control of the release (when testers control the release, they also must bear the full responsibility for the quality of the product)

 

Lesson 13: Beware of the not-my-job theory of testing

  • Do not adopt this philosophy
  • Also, find out what is expected of you

 

Lesson 14: Beware of becoming a process improvement group

  • You can work on improving the process as a team, but be careful not to criticise

 

Lesson 15: Don’t expect anyone to understand testing, or what you need to do it well

  • Remember that it’s up to you to tell your clients what you need and explain testing to them

Writing Test Cases

This above image was used with permission from Testlodge

This week I am focusing on writing test cases and I have been doing research on how to write them effectively. According to the ISTQB glossary, the definition of a test case is, “A set of preconditions, inputs, actions (where applicable), expected results and postconditions, developed based on test conditions. “

Different companies have different test case templates which work for them according to their likes and needs. Here are some of the fields that are included when writing a test case:

  • Test Case ID – a unique ID is needed for each test case, eg: “TC_1”
  • Test Name – test case title, eg: “Verify login page with valid username and password”
  • Test Description – this is describing the test objective
  • Pre- Conditions – prerequisites that need to be completed before test execution
  • Test Steps – this is a list of all execution steps. It should be detailed and in order from beginning to end
  • Test Data – data that can be used in your test case such as username and password for login, etc.
  • Expected Results – this is how we expect the function to work after testing it
  • Actual Results – this describes the system behaviour after test execution
  • Status – to say if the test passed or failed
  • Some others could include Test Priority, Test Designed By, Test Design Date, Test Executed By, Test Execution Date, etc.

 

There are many ways to make sure you are writing effective and good test cases:

  • You should make sure that your test cases are simple and clear. Anyone should be able to read them and know what to do. 
  • Try to get as much coverage by making sure you write test cases to check all requirements. Test all function/conditions.
  • Use different techniques to help find bugs. You can use techniques such as Boundary Value Analysis, Equivalence Partitioning, Error Guessing, etc.
  • Ask a colleague or someone to review your test cases.

Head First Python

I started reading Head First Python, 2nd Edition this week to start learning Python for Automation Testing. I am thoroughly enjoying it so far. It is very helpful that it has images, humour and good lessons in it- it makes it easier and more entertaining to read than just a long book filled with information that can be quite difficult to take in. I have only read chapter 1 so far and i am doing the exercises and making notes as I go.

 

Here are some starting hints that I took down:

  • Python comes with a built-in IDE called IDLE. IDLE lets you create, edit and run your code.
  • IDLE interacts with the Python interpreter (the interpreter runs your code).
  • Python comes with a standard library (provides access to a lot of reusable modules).
  • You make decisions with the if/ elif/ else statement.
  • Functions are inside modules, inside the standard library.

 

Here are a few things I have learnt how to do from this book so far:

1- To find out what system your interpreter is running on:

     >>> import sys

     >>> sys.platform

 

2- To see what version of Python is running:

     >>> print(sys.version)

 

3- To see the name of the folder your code is operating with:

     >>> import os

     >>> os.getcwd()

 

4- To see todays date:

     >>> import datetime

     >>> datetime.date.today()

 

5- To see date as a string:

     >>> datetime.date.isoformat(datetime.date.today())

 

6- To see what the time is:

     >>> import time

     >>> time.strftime (“%H:%M”)

 

7- Iterating over a sequence of objects:

     >>> for i in “Hi!”:

                 print (i)

 

8- Iterating a specific number of times:

     >>> for num in range (3):

                print (‘Python’)

 

9- Use sleep function to pause execution of code:

     >>> import time

     >>> time.sleep (5)

 

10- Generate a random integer

     >>> import random

     >>> random.randint (1,60)

 

I am learning that one of the great strengths of Python is that you can get a lot done with a few lines of code. Most tutorials that I have tried always start with Hello World, but this book dives a little bit deeper than that, which is great. I look forward to learning how to do much more and eventually using Python for Test Automation.  

Why Choose Python?

As a Software Tester wanting to go into Test Automation, I am currently learning a programming language called Python. Python is a high-level, interpreted and general-purpose language. It can be used to build just about anything. Python was released in 1991 and was named after the television show Monty Python’s Flying Circus.

 

 

While I was reading about which language to learn, I took notes on why people chose Python over other programming languages and here are some pointers that i found:

 

1- Less Code, Less Time, Less money

     Python typically involves less code which means that it would take less time to complete

     whatever you are working on

     – This allows you to work more quickly and efficiently

     – It also means less money will be spent

 

2- Simple and Easy to Learn

     Python is a simple language which is easy to read and learn

     – It is clear and easy to understand

     – It reads like English

        Eg: If you want to type Hello, World!, all you would need to type is: print(“Hello, World!”)

 

3- It is a High-Level Language

     You never have to worry about low-level details such as managing the memory used by your

     programme, etc.

 

4- Popularity/ Future

     According to the TIOBE index, Python is the third most popular programming language

     and it is growing very quickly

Source: http://www.tiobe.com/index.php/tiobe_index

 

5- Open Source Frameworks and Tools

     Python is an open source programming language.

     – You can also use several open source Python frameworks, libraries and development

        tools such as Django, PyQT, etc.

 

6- Flexible

     Python is very flexible, as it is a dynamically typed language

 

 

Python is suitable for many things, such as: building web applications, games development, scripting, data science, and AI and machine learning. Some large companies that use Python include: Google (YouTube), Facebook (Tornado), Dropbox, Yahoo, NASA, IBM, Mozilla and Quora.

How to generate a PDF from html with wkhtmltopdf in laravel

Recently, I had to develop a functionality in a laravel web application that allows users of the application to generate a pdf. I was clueless on how to go about it as it was something that I had never done before. My first port of call was to seek help on google.The search phrase that I used on google was "how to generate a pdf using laravel". As just any other search on google I got a lot of search results. A few of the search results that piqued my interest were :

I had a chance to use these pdf generator solutions and they all have their pros and cons. For me, the one that stood apart was laravel-snappy. It works like a charm once it has been configured in your local environment or remote server. Laravel-snappy is a wrapper for wkhtmltopdf used to convert html to pdf. It is used for server side rendering.
Wkhtmltopdf is an open source (LGPLv3) command line tool used to render HTML into PDF and using the Qt WebKit rendering engine. What I particularly like about this package is that it runs Javascript and it supports bootstrap. It was a bit of a mission to make it work on my Mac but finally I cracked it. In the next section I'm going to show you how I was able to generate a pdf on a laravel application using wkhtmltopdf.

Requirements
Firstly we are going to download a suitable version of wkhtmltopdf from their website and install it. The installation method is either

NB: When installing wkhtmltopdf please ensure that you install dependencies such as libXrender if they are not installed already.

Once you are done with the installation of wkhtmltopdf you may conduct a test to check if its properly installed. You do that by opening your console terminal, type in "wkhtmltopdf -V" or "wkhtmltopdf --version" and press enter.

After that we can install the Laravel-snappy package. We do that by requiring the package the composer.json file and then executing a composer update.

composer require barryvdh/laravel-snappy
composer update

Laravel

After the steps above  add the ServiceProvider to the providers array in config/app.php file.

Barryvdh\Snappy\ServiceProvider::class,

For shorter code you can add the following to your facades inside of the config/app.php file.

'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,

After you are done with all the steps above you then move on to publish the config/app.php class.

php artisan vendor:publish --provider="Barryvdh\Snappy\ServiceProvider"

Snappy config file

The major change in this file will be the path to the binaries. Since we installed wkhtmltopdf globally on our Mac we can do this by changing the path to:

'binary' => 'wkhtmltopdf',

Usage
If you have followed all the steps mentioned above you should be able to use the package to generate a pdf inside of a laravel application. Inside of a controller function you should be able to implement something like this:
<?php

namespace App\Http\Controllers;
use App\Inventory;

class MerchandiseController extends Controller
{
public function printInventory(){
$inventory = Inventory::get()->toArray();
$inventory_pdf = PDF::loadView('inventory_template', $inventory)
return $inventory_pdf->download('inventory.pdf');
}
}
?>
You then have to create inventory_template, a blade template with the html to be rendered to pdf in the resources/view directory or any other path you so choose.

AI Systems that Seek to Protect the Environment

I watched a video recently about how AI is helping to save endangered species and forests. This heading caught my attention as I love nature and environmental studies and I am now working in the IT industry. I decided to read up a bit more on AI and also how it can help environmental issues. AI can process huge amounts of data in a short time period, which allows us to work on projects that would otherwise be impossible. AI will not save our planet, but is a way that will help us get there. Using AI, environmentalists are currently measuring Earth’s resources so that they can monitor and try to manage them.

 

The WildMe project is an example of this: It helps identify and track wildlife populations. Photographs of animals are uploaded onto an open source platform by researchers and citizens. An AI system identifies each animal by its markings and features and records the location and the time that the image was taken. This allows researchers and scientists to track migration patterns and this also lets the users track the animal that they took a photograph of.

Silviaterra project is using AI to improve forest management in America. The software uses satellite imagery to assess forests. The satellite imagery records species of the trees, their height and the density of the forest.

Microsoft partnered up with USC CAIS’s AI for Conservation program and is applying AI to wildlife protecting using unmanned aerial vehicles with infrared cameras and Microsoft Azure Machine Learning. This will help detect animals and poachers over a wide area. Many animals are being poached such as Rhinoceroses and Elephants, just to name a few. This project can help decrease the amount of animals poached and help species from becoming extinct.

The Yield has been working with farmers to deploy sensors throughout their fields for instant status updates on their crops. This is powered by the Azure IoT Suit. The sensors absorb this data and combine it with weather data in the Microsoft cloud, then The Yield uses machine learning to deliver applications that help farmers know when to plant, irrigate, feed, protect, and harvest their crops.

 

These are only a few projects that I have mentioned that are using AI to help contribute to save our planet and help solve environmental issues. There are a lot more out there and there are also many projects that are still in development. Instead of people spending thousands of hours just going through images for example, we can now save a lot of time with the help of AI.

Test Automation Benefits

“Test automation increases the overall software efficiency and ensures robust software quality.”

Firstly, to get an idea of what Automation Testing is, here are two definitions explaining manual testing and automation testing:

  • Manual testing is performed by a human sitting in front of a computer carefully executing the test steps.
  • Automation testing means using an automation tool to execute your test case suite.

The goal of Automation testing is to reduce the number of test cases executed manually, but not get rid of manual testing altogether.

 

Test automation provides faster feedback, accelerated results and more testing efficiency.

Automated tests can be run virtually unattended, leaving the results to be monitored towards the end of the process. You can run automated tests overnight!

Test Automation helps to detect defects earlier. The earlier a defect is detected, the more cost-effective it will be to fix.

Manual testing can sometimes be seen as tedious, especially when test cases are repetitive and time consuming. Automation allows testers to focus on more challenging and rewarding work such as risk analysis and exploratory testing.

Humans are not perfect and testers can make mistakes during manual testing. Automated tests perform the same steps and always records detailed result, this helps to improve accuracy.

With test automation, many more tests can be executed which will lead to increased test coverage.

 

Test Automation has many benefits (as seen above) and can also be very useful when using agile methodologies. To fulfil the needs for fast deployment, testing methods need to be faster.”