This document provides an overview of test-driven development (TDD). It defines TDD as a technique for building software where tests are written before code to guide development. The key aspects of TDD covered are:
- Writing tests first before code, which helps improve design and ensures tests are written.
- The TDD mantra of Red-Green-Refactor, where tests initially fail (Red), code is written to pass tests (Green), then code is refactored to improve design.
- An example case study of a large Java project developed using TDD that has over 20,000 lines of unit tests providing over 90% test coverage.
Test-Driven Development is about approaching software development from a test perspective and knowing how to use the tools (e.g. JUnit, Mockito) to effectively write tests.
Source code examples @...
https://github.com/codeprimate-software/test-driven-development
Test-Driven Development is about approaching software development from a test perspective and knowing how to use the tools (e.g. JUnit, Mockito) to effectively write tests.
Source code examples @...
https://github.com/codeprimate-software/test-driven-development
Lets break some code. In this workshop we will be going over some of the fundamental concepts of software testing and take a hands on approach to writing Unit and Integration tests. We will cover topics such as mocking, stubbing, database patching and how this can all fit into a continuous integration environment like Jenkins.
4 Nisan 2015 tarihinde Kadir Has Üniversitesi'nde yapılan 9. Yazılım Teknolojileri Seminer etkinliğinde Eralp Erat'ın yaptığı TDD (Test Driven Design) sunumu
JUnit: A unit testing framework that is extensively used to test the code written in Java.
Unit testing is a type of software testing.
Software testing: The process of examining whether the software and its components meet the specified requirements
Other types of software testing are as shown.
Let's explore what is agile testing, how agile testing is different than traditional testing. What practices team has to adopt to have parallel testing and how to create your own test automation framework. Test automation frameworks using cucumber, selenium, junit, nunit, rspec, coded UI etc.
An introduction to unit testing using Visual Studio, C#, xUnit.net, and Moq. What it is, what is isn't, why we don't do it, how to design for testability, what to test, test driven development, unit testing frameworks, mocking libraries, how to get started.
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarApplitools
** Full webinar recording: https://youtu.be/D7vxFuwnUio **
Watch Sr. Architect Gil Tayar's special hands-on session, where he explains & demonstrates how Selenium and Cypress differ.
The session covers the following topics:
* How and why do frontend developers write tests
*Selenium architecture
*Cypress architecture
*Live Demo of Cypress - including how to write a Cypress test, and how it’s used
*How Cypress deals with flakiness
*Cypress and backdoors to development
*Visual Testing using Cypress
Test driven development (TDD), a software development method, helps build high quality applications faster. Life-cycle, usefulness, limitations and similar techniques of TDD have been presented in this slide deck.
Lets break some code. In this workshop we will be going over some of the fundamental concepts of software testing and take a hands on approach to writing Unit and Integration tests. We will cover topics such as mocking, stubbing, database patching and how this can all fit into a continuous integration environment like Jenkins.
4 Nisan 2015 tarihinde Kadir Has Üniversitesi'nde yapılan 9. Yazılım Teknolojileri Seminer etkinliğinde Eralp Erat'ın yaptığı TDD (Test Driven Design) sunumu
JUnit: A unit testing framework that is extensively used to test the code written in Java.
Unit testing is a type of software testing.
Software testing: The process of examining whether the software and its components meet the specified requirements
Other types of software testing are as shown.
Let's explore what is agile testing, how agile testing is different than traditional testing. What practices team has to adopt to have parallel testing and how to create your own test automation framework. Test automation frameworks using cucumber, selenium, junit, nunit, rspec, coded UI etc.
An introduction to unit testing using Visual Studio, C#, xUnit.net, and Moq. What it is, what is isn't, why we don't do it, how to design for testability, what to test, test driven development, unit testing frameworks, mocking libraries, how to get started.
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarApplitools
** Full webinar recording: https://youtu.be/D7vxFuwnUio **
Watch Sr. Architect Gil Tayar's special hands-on session, where he explains & demonstrates how Selenium and Cypress differ.
The session covers the following topics:
* How and why do frontend developers write tests
*Selenium architecture
*Cypress architecture
*Live Demo of Cypress - including how to write a Cypress test, and how it’s used
*How Cypress deals with flakiness
*Cypress and backdoors to development
*Visual Testing using Cypress
Test driven development (TDD), a software development method, helps build high quality applications faster. Life-cycle, usefulness, limitations and similar techniques of TDD have been presented in this slide deck.
This was a workshop given on the UTN University, for the Software Engineering students. The idea is to give a brief explanation about TDD, and how to use it.
We investigate one of the most popular approaches to creating software: test driven development. From the basic understanding why tests are important to a new software development paradigm, where you start with tests and them do the implementation. We glance over different areas of testing and see how one should really do the software testing in different situation.
Ever tried doing Test First Test Driven Development? Ever failed? TDD is not easy to get right. Here's some practical advice on doing BDD and TDD correctly. This presentation attempts to explain to you why, what, and how you should test, tell you about the FIRST principles of tests, the connections of unit testing and the SOLID principles, writing testable code, test doubles, the AAA of unit testing, and some practical ideas about structuring tests.
This is a 90 min talk with some exercises and discussion that I gave at the DHS Agile Expo. It places DevOps as a series of feedback loops and emphasizes agile engineering practices being at the core.
Implementing TDD in for .net Core applicationsAhmad Kazemi
This is a presentation I made to make decision on which tools and frameworks should we use in our new dotnet core application to implement test driven development.
In this session, we will take a deep-dive into the DevOps process that comes with Azure Machine Learning service, a cloud service that you can use to track as you build, train, deploy and manage models. We zoom into how the data science process can be made traceable and deploy the model with Azure DevOps to a Kubernetes cluster.
At the end of this session, you will have a good grasp of the technological building blocks of Azure machine learning services and can bring a machine learning project safely into production.
When it comes to microservice architecture, sometimes all you wanted is to perform cross cutting concerns ( logging, authentication , caching, CORS, Routing, load balancing , exception handling , tracing, resiliency etc..) and also there might be a scenario where you wanted to perform certain manipulations on your request payload before hitting into your actual handler. And this should not be a repetitive code in each of the services , so all you might need is a single place to orchestrate all these concerns and that is where Middleware comes into the picture. In the demo I will be covering how to orchestrate these cross cutting concerns by using Azure functions as a Serverless model.
In this talk, we will start with some introduction to Azure Functions, its triggers and bindings. Later we will build a serverless solution to solve a problem statement by using different triggers and bindings of Azure Functions.
Language to be used: C# and IDE - Visual Studio 2019 Community Edition"
In this workshop, you will understand how Azure DevOps Services helps you scale DevOps adoption strategies in enterprise. We will explore various feature and services that can enable you to implement various DevOps practices starting from planning, version control, CI & CD , Dependency Management and Test planning.
In this session, we will understand how to create your first pipeline and build an environment to restore dependencies and how to run tests in Azure DevOps followed by building an image and pushing it to container registry.
In this session, we will discuss a use case where we need to quickly develop web and mobile front end applications which are using several different frameworks, hosting options, and complex integrations between systems under the hood. Let’s see how we can leverage serverless technologies (Azure Functions and logic apps) and Low Code/No code platform to achieve the goal. During the session we will go though the code followed by a demonstration.
CREATING REAL TIME DASHBOARD WITH BLAZOR, AZURE FUNCTION COSMOS DB AN AZURE S...CodeOps Technologies LLP
In this talk people will get to know how we can use change feed feature of Cosmos DB and use azure functions and signal or service to develop a real time dashboard system
Imagine a scenario, where you can launch a video call or chat with an advisor, agent, or clinician in just one-click. We will explore application patterns that will enable you to write event-driven, resilient and highly scalable applications with Functions that too with power of engaging communication experience at scale. During the session, we will go through the use case along with code walkthrough and demonstration.
We will walk through the exploration, training and serving of a machine learning model by leveraging Kubeflow's main components. We will use Jupyter notebooks on the cluster to train the model and then introduce Kubeflow Pipelines to chain all the steps together, to automate the entire process.
It is difficult to deploy interloop Kubernetes development in current state. Know these open-source projects that can save us from the burden of various tools and help in deploying microservices on Kubernetes cluster without saving secrets in a file.
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...CodeOps Technologies LLP
Running day-1 Ops on your Kubernetes is somewhat easy, but it is quite daunting to manage day two challenges. Learn about AKS best practices for your cloud-native applications so that you can avoid blow up your workloads.
Prometheus is a popular open source metric monitoring solution and Azure Monitor provides a seamless onboarding experience to collect Prometheus metrics. Learn how to configure scraping of Prometheus metrics with Azure Monitor for containers running in AKS cluster.
What if you could combine Trello, GitLab, JIRA, Calendar, Slack, Confluence, and more - all together into one solution?
Yes, we are talking about Space - the latest tool from JetBrains famous for its developer productivity-enhancing tools (esp. IntelliJ IDEA).
Here we have explained about JetBrains' space and its functionalities.
This talk will serve as a practical introduction to Distributed Tracing. We will see how we can make best use of open source distributed tracing platforms like Hypertrace with Azure and find the root cause of problems and predict issues in our critical business applications beforehand.
This talk serves as a practical introduction to Distributed Tracing. We will see how we can make best use of open source distributed tracing platforms like Hypertrace with Azure and find the root cause of problems and predict issues in our critical business applications beforehand.
Presentation part of Open Source Days on 30 Oct - ossdays.konfhub.com
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
Your Digital Assistant.
Making complex approach simple. Straightforward process saves time. No more waiting to connect with people that matter to you. Safety first is not a cliché - Securely protect information in cloud storage to prevent any third party from accessing data.
Would you rather make your visitors feel burdened by making them wait? Or choose VizMan for a stress-free experience? VizMan is an automated visitor management system that works for any industries not limited to factories, societies, government institutes, and warehouses. A new age contactless way of logging information of visitors, employees, packages, and vehicles. VizMan is a digital logbook so it deters unnecessary use of paper or space since there is no requirement of bundles of registers that is left to collect dust in a corner of a room. Visitor’s essential details, helps in scheduling meetings for visitors and employees, and assists in supervising the attendance of the employees. With VizMan, visitors don’t need to wait for hours in long queues. VizMan handles visitors with the value they deserve because we know time is important to you.
Feasible Features
One Subscription, Four Modules – Admin, Employee, Receptionist, and Gatekeeper ensures confidentiality and prevents data from being manipulated
User Friendly – can be easily used on Android, iOS, and Web Interface
Multiple Accessibility – Log in through any device from any place at any time
One app for all industries – a Visitor Management System that works for any organisation.
Stress-free Sign-up
Visitor is registered and checked-in by the Receptionist
Host gets a notification, where they opt to Approve the meeting
Host notifies the Receptionist of the end of the meeting
Visitor is checked-out by the Receptionist
Host enters notes and remarks of the meeting
Customizable Components
Scheduling Meetings – Host can invite visitors for meetings and also approve, reject and reschedule meetings
Single/Bulk invites – Invitations can be sent individually to a visitor or collectively to many visitors
VIP Visitors – Additional security of data for VIP visitors to avoid misuse of information
Courier Management – Keeps a check on deliveries like commodities being delivered in and out of establishments
Alerts & Notifications – Get notified on SMS, email, and application
Parking Management – Manage availability of parking space
Individual log-in – Every user has their own log-in id
Visitor/Meeting Analytics – Evaluate notes and remarks of the meeting stored in the system
Visitor Management System is a secure and user friendly database manager that records, filters, tracks the visitors to your organization.
"Secure Your Premises with VizMan (VMS) – Get It Now"
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
4. What is TDD?
❖ Test-Driven Development (TDD) is a technique for
building software that guides software development by
writing tests. (Martin Fowler’s definition)
❖ “Test Driven Development” is NOT primarily about
testing or development (i.e., coding)
❖ It is rather about design - where design is evolved
through refactoring
❖ Developers write unit tests (NOT testers) and then code
5. TDD? But I already write unit tests!
❖ In Test Driven Development, tests mean “unit
tests” (Note that in variations/extensions such as
ATDD, tests are not unit tests)
❖ Just because unit tests are written in a team doesn’t
mean they follow TDD - they could be written even
after the writing code - that is Plain Old Unit testing
(POUting)
❖ However, when following Test Driven Development,
or Test First Development approach, we write the
tests first before actually writing the code
6. Writing tests after code: disadvantages
❖ There are many disadvantages in writing tests after code
❖ Testing does not give direct feedback to design and
programming => in TDD, the feedback is directly fed
back into improving design and programs
❖ Most of the times, after realising the functionality in
code, unit testing is omitted => TDD inverts this
sequence and helps create unit tests first
❖ Writing tests after developing code often results in
“happy path” testing => we don’t have enough
granular or “testable” code segments to write the tests
8. TDD mantra
❖ Red—write a little test that doesn’t work, perhaps
doesn’t even compile at first
❖ Green—make the test work quickly, committing
whatever sins necessary in the process
❖ Refactor—eliminate all the duplication and smells
created in just getting the test to work
Source: Test Driven Development: By Example, Kent Beck, 240 pages, Addison-Wesley Professional, 2002;
10. 3 laws of TDD
❖ Law 1: You may not write production code unless
you’ve first written a failing unit test.
❖ Law 2: You may not write more of a unit test than is
sufficient to fail.
❖ Law 3: You may not write more production code than is
sufficient to make the failing unit test pass.
Source: Professionalism and Test-Driven Development, Robert C. Martin, IEEE Software, 2007
11. TDD in action: Case study
Source: Professionalism and Test-Driven Development, Robert C. Martin, IEEE Software, 2007
❖ “Over the last few years, Micah Martin and I’ve been working on an application named
FitNesse (www.fitnesse.org).
❖ FitNesse is a Web-based application using a Front Controller that defers to servlets that
direct views.
❖ Downloaded tens of thousands of times, FitNesse consists of 45,000 lines of Java code in
nearly 600 files.
❖ Almost 20,000 of those lines and 200 of those files are unit tests.
❖ Over 1,100 specific test cases contain many thousands of assertions, giving FitNesse test
coverage of over 90 percent (as measured by Clover, http://cenqua.com/clover).
❖ These tests execute at the touch of an IDE (integrated development environment) button
in approximately 30 seconds.
❖ These tests, along with the convenience of easily executing them, have benefits that far
exceed simple software verification.”
12. TDD process cycle
1. Add a little test
2. Run all tests and fail
3. Make a little change
4. Run the tests and succeed
5. Refactor to remove duplication
14. –Ward Cunningham
“You know you are working on clean code when
each routine you read turns out to be pretty much
what you expected. You can call it beautiful code
when the code also makes it look like the language
was made for the problem.”
15. TDD - benefits
Better Design
Cleaner code (because of
refactoring)
Safer refactoring Increased quality
Better code coverage Tests serve as documentation
Faster debugging
Most often, the failing code/test is
in the most recently changed code
Self-documenting tests
Test-cases show/indicate how to
use the code
20. Unit testing: common excuses
❖ I am paid to write code, not tests!
❖ I am a developer, not tester - so I’m not responsible for writing tests!
❖ We already have tests - why do we need unit tests?
❖ We are working on a tight deadline - where do I have time for
writing unit tests?
❖ I don’t know how to write unit tests
❖ Ours is legacy code - can’t write unit tests for them
❖ If I touch the code, it breaks!
21. What dependencies can unit test have?
❖ A test is not a unit test if:
❖ It talks to the database
❖ It communicates across the network
❖ It touches the file system
❖ It can’t run at the same time as any of your other unit tests
❖ You have to do special things to your environment (such as
editing config files) to run it.
— Michael Feathers, in A Set Of Unit Testing Rules (2005)
22. The law of low-hanging fruit!
Start with something really simple. Implement an obvious test case.
24. JUnit
Original developers Kent Beck, Erich Gamma
Stable release JUnit 4.12
GitHub repo
https://github.com/junit-
team/junit4
License Eclipse Public License (EPL)
Website www.junit.org
Source: wikipedia
25. –Martin Fowler (on JUnit)
"Never in the field of software engineering has so
much been owed by so many to so few lines of code."
26. Getting started with JUnit
❖ Step 1: Download and Install JUnit
❖ https://github.com/junit-team/junit4/wiki/
Download-and-Install
❖ Step 2: Try “Getting Started” example:
❖ https://github.com/junit-team/junit4/wiki/Getting-
started
27. JUnit
❖ Tests are expressed in ordinary source code
❖ The execution of each test is centered on an instance of a TestCase
object
❖ Each TestCase, before it executes the test, has the opportunity to
create an environment for the test, and to destroy that environment
when the test finishes
❖ Groups of tests can be collected together, and their results of running
them all will be reported collectively
❖ We use the language’s exception handling mechanism to catch and
report errors
Source: Test Driven Development: By Example, Kent Beck, 240 pages, Addison-Wesley Professional, 2002;
29. Assert methods in JUnit
assertEquals()/
assertNotEquals()
Invokes the equals() methods on the arguments to check
whether they are equal
assertSame()/
assertNotSame()
Uses == on the arguments to check whether they are equal
assertTrue()/
assertFalse()
Checks if the given boolean argument evaluates to true or false
assertNull()/
assertNotNull()
Checks if the given argument is null or NOT null
assertArrayEquals()
Checks if the given array arguments passed have same elements
in the same order
30. Arrange-Act-Assert (AAA) Pattern
• Arrange: Setup things needed to execute the tests
• Act: Invoke the code under test
• Assert: Specify the criteria for the condition to be met for the test to pass (or
else, it is test failure)
@Test
public void evaluatePlus() {
// Arrange
Expr exprNode = new Plus(new Constant(10), new Constant(20));
// Act
int evalValue = exprNode.eval();
// Assert
assertEquals(evalValue, 30);
}
31. Test fixtures
❖ You can provide a text fixture to ensure that the test is
repeatable, i.e., start in the same state so it produce the
same results and clean up after running the tests.
❖ You can use @Before typically to initialise fields.
Similarly you can use @After to execute after the test is
complete.
32. Unit testing best practices
❖ Test name should reflect the intent/purpose & describe the
feature/specification
❖ Unit test should test a single concept
❖ Readability matters in the tests - use comments as appropriate
❖ Test code also needs maintenance and factors like readability
are important (just like production code)
❖ Tests obvious functionality as well as corner cases - both are
important
34. Duplicate code in unit tests?
❖ Duplicate code segments in
code is bad
❖ Violates ‘Don’t Repeat
Yourself’ principle
❖ Duplicate code segments in
tests is often needed
❖ To test similar but slightly
different functionality
Isn’t
^C and ^V
bad?
38. Terminology
❖ System Under Test (SUT) is the part of the system being
tested - and could be of different levels of granularity
like a class or an application.
❖ Depended On Component (DOC) means the entity that
SUT requires to fulfil its objectives.
❖ Mocking can be used to decouple SUT from DOCs -
this enables unit tests to run independently
39. Test “doubles”
❖ Simplest one is stub
❖ It is a temporary one that does nothing and stands for the real
object
❖ More sophisticated than stub is a fake
❖ It provides an alternative simple implementation than the
original one
❖ Mocks simulate the original object
❖ Provides implementation of the object with assertions,
returning hard-coded values, etc
41. Fakes
❖ Fake is a type of test double.
❖ It is simpler, easier, or cheaper to use than the actual
dependency.
❖ An example is using “HSQLDB” (in-memory database)
instead of actual “Microsoft SQL” database.
❖ Fakes are mainly used in integration tests.
42. Why “test doubles”?
❖ Allow us to implement the code for specific
functionality without getting all the dependent code in
place (without getting “dragged down” by
dependencies)
❖ Can independently test only the given functionality
❖ If it fails, we know its because of the given code and
not due to dependencies
43. Stub-outs
❖ Plumbing - “Stub-Outs” - Short pipes put in early during plumbing work during
constructions - eventually, they will be replaced with real pipes and fixtures.
51. References
❖ Wikipedia page - JUnit: https://en.wikipedia.org/
wiki/JUnit
❖ Wikipedia page - Test Driven Development: https://
en.wikipedia.org/wiki/Test-driven_development
❖ Professionalism and TDD: https://8thlight.com/blog/
uncle-bob/2014/05/02/ProfessionalismAndTDD.html
❖ Preparatory refactoring: https://martinfowler.com/
articles/preparatory-refactoring-example.html
52. Recommended reading
Test Driven Development: By Example, Kent Beck, 240 pages, Addison-Wesley Professional, 2002;
Classic on TDD by its
originator Kent Beck
53. Recommended reading
Covers principles, best
practices, heuristics,
and interesting
examples
Growing Object-Oriented Software, Guided by Tests, Steve Freeman, Nat Pryce, Addison Wesley, 2009
54. Recommended reading
Covers design smells
as violations of design
principles
“Refactoring for Software Design Smells: Managing Technical Debt”, Girish Suryanarayana, Ganesh Samarthyam, Tushar Sharma, ISBN - 978-0128013977, Morgan
Kaufmann/Elsevier, 2014.