25,19 €
Learn Java programming concepts to design automation testing frameworks
Java is one of the most commonly-used software languages by programmers and developers. Are you from a non-technical background and looking to master Java for your automation needs? Then Hands-On Automation Testing with Java for Beginners is for you.
This book provides you with efficient techniques to effectively handle Java-related automation projects. You will learn how to handle strings and their functions in Java. As you make your way through the book, you will get to grips with classes and objects, along with their uses. In the concluding chapters, you will learn about the importance of inheritance and exceptions with practical examples.
By the end of this book, you will have gained comprehensive knowledge of Java.
Hands-On Automation Testing with Java for Beginners is for software developers who want to step into the world of software quality assurance and perform automation testing using various testing frameworks. Prior experience of writing tests in Java is assumed.
Rahul Shetty has worked with various CMM-level organizations and has managed the setting up of QA processes for projects.Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 146
Veröffentlichungsjahr: 2018
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Pavan RamchandaniAcquisition Editor: Shriram ShekharContent Development Editor: Zeeyan PinheiroTechnical Editor: Romy DiasCopy Editor: Safis EditingProject Coordinator: Vaidehi SawantProofreader: Safis EditingIndexer: Rekha NairGraphics: Alishon MendonsaProduction Coordinator: Aparna Bhagat
First published: September 2018
Production reference: 1280918
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78953-460-3
www.packtpub.com
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Rahul Shetty has worked with various CMM-level organizations and has managed the setting up of QA processes for projects.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Hands-On Automation Testing with Java for Beginners
Packt Upsell
Why subscribe?
Packt.com
Contributors
About the author
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
First Programming Steps in Java
An introduction to Java and its installation
Working with the Java editor tools
Writing your first executable program in Java
Summary
Understanding Classes, Objects, and Their Usage in Java
Difference between strings and variables
Using methods
Importance of classes and objects in Java
Creating an object in Java
Accessing an object in Java
Accessing a method in a different class
Summary
Handling Strings and Their Functions in Java
Introducing strings
Defining the String literal
Creating an object of the String class
The String class and its methods
Reversing a string's logic
Summary
Building Blocks for Java Programs – Loops and Conditions
The for loop
if...else condition
Bringing the if...else condition in the for loop
The while loop
The do...while loop
Nested loops
Example 1
Example 2
Example 3
Summary
Everything You Need to Know About Interfaces and Inheritance
Interfaces
Using interfaces with a traffic light system
Inheritance
More on inheritance
Function overloading
Function overriding
Summary
Learn Everything about Arrays
Arrays and their usage in Java programs
Ways to initialize arrays and assign objects
Multidimensional arrays
Logic programming on multidimensional arrays
Practice exercises
Print the smallest number in a 3 x 3 matrix
Displaying the largest number from the column with the smallest number
Swapping variables with/without the temp variable
Summary
Understanding Date Class and Constructors in Java 11
The Date class
The Calendar class
Constructors
Parameterized constructors
Summary
Importance of the super and this Keywords and Exceptions in Java
The super keyword
Practical usage of the super keyword
Using the super keyword for methods
Using the super keyword for constructors
Importance of the this keyword
Different kinds of exception
The try...catch mechanism to handle exceptions
Importance of the finally block in Java
Summary
Understanding the Collections Framework
The collections framework
The List collection
The ArrayList class
Example of ArrayList
The Set collection
Using iterator
The Map collection
HashTable
Synchronized or thread-safe
Null keys and null values
Iterating values
Summary
The Importance of the final Keyword, Packages, and Modifiers
The final keyword
Packages
Modifiers in Java
default
public
private
protected
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Java is one of the most commonly used software languages by programmers and developers. Are you from a non-technical background and looking to master Java for your automation needs? Then this book is for you.
This book is a guide that describes efficient techniques for effectively handling Java-related automation/projects. You will learn how to handle strings and their functions in Java. As we move, you will get to grips with classes, objects, and their usage. This book will help you understand the importance of inheritance and exceptions with practical examples.
By the end of this book, you will have gained a comprehensive knowledge of Java that will help you crack any job interview.
This book is intended for software developers who want to step into the world of software quality assurance and perform automation testing using testing frameworks. This book assumes Java programming experience for writing tests.
Chapter 1, First Programming Steps in Java, will introduce Java to you, along with the steps for installation and writing a small program to get started.
Chapter 2, Understanding Classes, Objects, and Their Usage in Java, will cover the basic concepts, such as strings and variables, and how they are different from each other. We will also discuss objects and their importance.
Chapter 3, Handling Strings and Their Functions in Java, will show you how to define a string using the String class, using an example to demonstrate.
Chapter 4, Building Blocks for Java Programs – Loops and Conditions, will help you to understand important loops through examples.
Chapter 5, Everything You Need to Know About Interfaces and Inheritance, will cover some important concepts, such as interfaces, inheritance, function overloading, and function overriding.
Chapter 6, Learning Everything about Arrays, will cover one of the most important concepts in Java, arrays; we will look at a few examples to understand the working of arrays.
Chapter 7, Understanding Date Class and Constructors in Java 11, will dive into the Date class and constructors in detail.
Chapter 8, Importance of the super and this Keywords and Exceptions in Java, is all about two keywords: super and this. We will pick examples and explain how they are put to use in various situations while writing our Java code.
Chapter 9, Understanding the Collections Framework, will dive deep into the collections framework, which consists of interfaces and classes. We will have a look at the three major collections: List, Set, and Map. In addition, ArrayList from the List collection, HashSet from the Set collection, and HashMap and HashTable from the Map collection, will be discussed in this chapter.
Chapter 10, The Importance of the final Keyword, Packages, and Modifiers, will cover some important concepts, including the final keyword and importance of packages and modifiers in Java.
Any prior knowledge of Java would be helpful during the course of the book.
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packt.com
.
Select the
SUPPORT
tab.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Automation-Testing-with-Java-for-Beginners. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "To check whether Java is installed in our machine, navigate to C:\Program Files."
A block of code is set as follows:
package coreJava;public class finaldemo { public static void main(String[] args) { //TODO Auto-generated method stub
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
protected void abc() { //TODO Auto-generated method stub System.out.println("
Hello
");}
Any command-line input or output is written as follows:
$ import package.classname
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Keep clicking on Next so that Java is successfully configured in our machine."
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.
Welcome to Hands-On Automation Testing with Java for Beginners. This is the only book you will find on the internet that teaches every topic needed to emerge as a strong Java automation tester. It contains easy teaching and simple techniques to effectively handle Java-related automation/projects. Considering that we will cover each and every topic of core Java, with detailed explanations, this will really help us develop and grade our own Java automation projects.
All the core Java concepts are explained from scratch. We do not assume that readers have any prerequisite knowledge, so we consider all readers to be from a non-coding background, and we teach each and also support them with examples that we will use in real time. Hence, we will not stick to only theories.
When you check for courses in the market, you should try to learn one new concept. You just see three lines of definition followed by examples; that's all. But here, we will understand why, when, and where we are using the object-oriented programming systems (OOPS) concept in Java. There will also be proper programming examples, showing a particular OOPS concept in real-time usage. In this way, our book will drive through real-time projects; it's all about practical learning. This will come into play when we start with Java collections, such as core Java, which is one of the main concepts in our book since it is definitely required for you to start your basics and to develop an automation framework in your workplace. Also, since Java collections is one of the core parts, throughout the entire book we will take utmost care in providing all the necessary practical scenarios for each Java collection that we will discuss.
We will be working on tricky Java programs, looking at printouts, prime numbers, Fibonacci series, and pyramids. We will sort out print in descending order, looking at array matrices, and printing the maximum column numbers. This book will provide you with detailed strategies and tips that you will need to use when approaching and designing a logic for these programs. This will help you to think beyond the boundaries and get the logic that you will need to write difficult Java programs.
Programs discussed in this book derive from commonly asked questions during interviews in many companies. You will receive help with those questions, with detailed solutions, and the methodology to approach that logic. So, this book is mainly focused on core Java. We are not dealing with swings and buttons, which are out of scope for Java learning in this book.
In this book, we will be learning core Java, collections, and other concepts such as loops, classes, and arrays . These are more than enough for you to start and develop a Java project. Whichever field you are put in, the knowledge gained from this book will help you start testing in the automation projects right away.
This chapter will cover the following concepts:
An introduction to Java and its installation
Working with the Java editor tools
Writing your first executable program in Java
The first thing that comes to mind when we speak about Java is that it is platform-independent. This feature has made Java a hot programming tool in the market. So what exactly does platform-independent mean?
The code that we write is independent of the environment; be it Windows, Unix, Linux, or Solaris. Basically, when we write a Java program, the Java compiler converts the program to bytecode. When we run the Java code, the Java compiler converts the entire programming code to bytecode. For example, we are working on a Windows machine. When we run the program and the Java compiler runs and creates bytecode for us, this bytecode can be taken and executed on any other platform, such as Linux, macOS, and Unix. So this means we are developing a bytecode in Windows, and that bytecode is runnable on any other platform. So this is what we mean by platform-independent.
