The document discusses unit testing and proposes an alternative approach called reality-driven testing. It begins with a warning that the topic may be controversial and definitions of different types of tests. It then discusses issues with unit testing like tight coupling to implementation, high cost, and limited purpose. The document proposes a pyramid-driven testing approach with more integrated tests at higher levels. It provides an example of writing functional tests against requirements before showing example code for components like a solar calculator that could be tested with this approach.
Android Deobfuscation: Tools and Techniquescaleb194331
Malware analysts are increasingly faced with the challenge of reverse engineering obfuscated code. This talk describes several obfuscation techniques and two new deobfuscation tools: dex-oracle and Simplify.
Breaking Dependencies to Allow Unit TestingSteven Smith
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Steven Smith
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
This talk presents apkfile, a library for extracting machine learning features from Android apps as well as describing several interesting, high-value features for malware detection such as compiler fingerprinting, anti-vm detection, and Markov models for detecting unusual strings. Additionally, it provides tips for improving model performance with data preparation, feature selection, model tuning, and model blending.
Slides from the talk "CI doesn’t start with Jenkins" from DevOps Stage 2018 (12-13 October 2018, Kyiv, Ukraine)
CI is not only a tool. You cannot simply install and configure Jenkins or whatever system and say that you have CICD pipeline. Here I'm trying to cover different aspects and dependencies of the CICD process based on Preply Inc experience.
External Links:
[2] CatOps Telegram channel: https://t.me/catops
[2] HashiCorp User Group Kyiv: https://www.meetup.com/Kyiv-HashiCorp-User-Group/
[12-24 ]https://www.endpoint.com/blog/2014/05/02/git-workflows-that-work
[49-50]: https://nvie.com/posts/a-successful-git-branching-model/
[51-56]: https://www.toptal.com/software/trunk-based-development-git-flow
[64] Django Anonymizer: https://github.com/knowledge-point/dj_anonymizer
Projects Valhalla and Loom at IT Tage 2021Vadym Kazulkin
In this presentation, we will explain the motivation, added values, challenges and current status of the Valhalla and Loom projects.
In the Valhalla project, Inline Type is introduced in Java. Inline Type is an immutable type that differs only by the state of its properties. The purpose is to reduce memory consumption and access times for such data types. Also as a part of this project Java type system will be unified so that Java will become a pure object-oriented programming language.
In the Loom project, lightweight threads are implemented in Java. The purpose is to no longer trade off between simplicity and scalability of the source code and to reconcile both.
Improving the Quality of Existing SoftwareSteven Smith
How do you improve the quality of your existing software, while continuing to add value for your customers? What are some heuristics and code smells you can look for, and principles and patterns you can use to guide you, as you make your software better over time instead of worse?
How do you tame a big ball of mud? One test at a time.Matt Eland
A broad and high level overview of .NET unit test libraries that will help you write better tests. Discussions around Scientist .NET, Bogus, AutoFixture, Snapper, and others.
Android Deobfuscation: Tools and Techniquescaleb194331
Malware analysts are increasingly faced with the challenge of reverse engineering obfuscated code. This talk describes several obfuscation techniques and two new deobfuscation tools: dex-oracle and Simplify.
Breaking Dependencies to Allow Unit TestingSteven Smith
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Steven Smith
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
This talk presents apkfile, a library for extracting machine learning features from Android apps as well as describing several interesting, high-value features for malware detection such as compiler fingerprinting, anti-vm detection, and Markov models for detecting unusual strings. Additionally, it provides tips for improving model performance with data preparation, feature selection, model tuning, and model blending.
Slides from the talk "CI doesn’t start with Jenkins" from DevOps Stage 2018 (12-13 October 2018, Kyiv, Ukraine)
CI is not only a tool. You cannot simply install and configure Jenkins or whatever system and say that you have CICD pipeline. Here I'm trying to cover different aspects and dependencies of the CICD process based on Preply Inc experience.
External Links:
[2] CatOps Telegram channel: https://t.me/catops
[2] HashiCorp User Group Kyiv: https://www.meetup.com/Kyiv-HashiCorp-User-Group/
[12-24 ]https://www.endpoint.com/blog/2014/05/02/git-workflows-that-work
[49-50]: https://nvie.com/posts/a-successful-git-branching-model/
[51-56]: https://www.toptal.com/software/trunk-based-development-git-flow
[64] Django Anonymizer: https://github.com/knowledge-point/dj_anonymizer
Projects Valhalla and Loom at IT Tage 2021Vadym Kazulkin
In this presentation, we will explain the motivation, added values, challenges and current status of the Valhalla and Loom projects.
In the Valhalla project, Inline Type is introduced in Java. Inline Type is an immutable type that differs only by the state of its properties. The purpose is to reduce memory consumption and access times for such data types. Also as a part of this project Java type system will be unified so that Java will become a pure object-oriented programming language.
In the Loom project, lightweight threads are implemented in Java. The purpose is to no longer trade off between simplicity and scalability of the source code and to reconcile both.
Improving the Quality of Existing SoftwareSteven Smith
How do you improve the quality of your existing software, while continuing to add value for your customers? What are some heuristics and code smells you can look for, and principles and patterns you can use to guide you, as you make your software better over time instead of worse?
How do you tame a big ball of mud? One test at a time.Matt Eland
A broad and high level overview of .NET unit test libraries that will help you write better tests. Discussions around Scientist .NET, Bogus, AutoFixture, Snapper, and others.
Improving the Quality of Existing SoftwareSteven Smith
The document discusses techniques for improving the quality of existing software, including reducing technical debt, following principles like DRY and SOLID, using characterization tests to preserve behavior during refactoring, and improving skills to write higher quality code faster. It covers topics like refactoring, test-driven development, dependency inversion, and design patterns. The goal is to maintain and enhance application code quality over time through refactoring and preventing technical debt.
Improving the Quality of Existing SoftwareSteven Smith
Given at DogFoodCon 2016 in Columbus, Ohio
As developers, most of our time is spent working on existing software – even if it’s just the software we wrote ourselves, yesterday. And over time, software rots. If were not diligent, our beautiful code can degrade into a worthless mess. Keeping our code in working condition is no different than changing the oil in our car “ its preventive maintenance. In this session, Steve will cover some common places to look for signs of degradation in existing applications, and describe the steps we can take to improve our code. Examples will use C# and primarily ASP.NET.
Improving the Quality of Existing Software - DevIntersection April 2016Steven Smith
How do you improve the quality of your existing software, while continuing to add value for your customers? What are some heuristics and code smells you can look for, and principles and patterns you can use to guide you, as you make your software better over time instead of worse? How can we improve our skills and techniques so that writing high quality software becomes our default, fastest way of working?
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
You will learn why naming is really difficult if done right, why coding and style guidelines are crucial, code structuring, exception handling and why other elements of coding often define the tipping point between success and failure of projects. Following the principles of software craftsmanship will allow you to end up with better maintainability and extensibility of your software and the success of the project in the end. All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation.
Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs. Writing clean code can significantly lower these costs. However, writing clean code also makes you more efficient during the initial development time and results in more stable code. You will be presented design patterns and best practices which will make you write better and more easily maintainable code, seeing code in a holistic way. You will learn how to apply them by using an existing implementation as the starting point of the presentation. Finally, patterns & practices benefits are explained.
This presentation is based on C# and Visual Studio 2012. However, the demonstrated patterns and practice can be applied to every other programming language too.
The Cowardly Test-o-Phobe's Guide To TestingTim Duckett
The document discusses testing iOS applications. It begins by addressing why testing can be scary and introduces test-driven development as an approach to make testing less scary. It then covers different tools for testing iOS apps, including frameworks for unit testing and UI testing. It emphasizes the importance of mocking and stubbing dependencies to isolate parts of the code for testing. The document also discusses approaches for testing network requests, such as using a tool called OHHTTPStubs to stub network responses from files. It concludes by encouraging testing user interfaces in code and using mocking/stubbing to handle dependencies.
Clan code is extremely essential to build scalable application which can be maintained quite easily and improved further
Slide was prepared with contribution to my colleague
and i thank them for the help!
Learn How to Unit Test Your Android Application (with Robolectric)Marakana Inc.
The document discusses the Android unit test framework Robolectric. It provides an overview of Robolectric, including how it works by using shadow objects to simulate the Android framework classes, allowing tests to run on a normal JVM. It also covers how to get started with Robolectric by using the sample project, and how to write tests by accessing shadow objects and dealing with classes that don't expose full state.
This document provides a guide to resources for learning about the Selenium testing tool. It lists 25 different resources organized into categories like documentation, videos, books, blogs, forums, meetups and more. These include the Selenium HQ website, wiki, blogs, mailing lists, online groups, conferences and more. The document aims to help beginners, intermediate and advanced users find relevant Selenium information.
Learn the best QA / Testing Tools, Automation Testing tools and techniques Online & Classroom Training from the industry experts at Magnitia IT.
https://www.magnitia.com/testing-courses.html
Projects Valhalla, Loom and GraalVM at JCon 2020Vadym Kazulkin
This document summarizes Projects Valhalla, Loom and GraalVM. Project Valhalla aims to introduce inline types (value types) to Java to improve performance by reducing memory usage and indirection. Project Loom introduces virtual threads and continuations to allow writing scalable and asynchronous code more easily. GraalVM is a high-performance polyglot virtual machine for Java and other languages.
It is always tough to test a complex API comprehensively. The additional level of complexity brings us to the question “How can we validate that our API is working as intended?”
In this talk I will explain how to use test driven development for APIs to solve this problem and even further how TDD can drive an API Design towards a more usable design. I will outline my practical approach with an implementation example based on django. And finally I will give you a brief summary of my lessons learned using this approach in customer projects.
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Alan Richardson
This document provides an overview of a half-day tutorial on building abstraction layers for web automation tests using Selenium WebDriver. The tutorial will cover common approaches to modeling web applications and constructing page object and other abstraction layers. Attendees will participate in exercises to experiment with different abstraction techniques using a sample todo list application. The session will discuss topics like page object design, element abstractions, domain objects, and component abstractions. Code examples demonstrating various abstraction implementations will also be presented and analyzed.
Generalization in Auto-Testing. How we put what we had into new Technological...SQALab
This document discusses generalization in test automation and the XML2Selenium test automation platform. It provides an overview of the platform's architecture, including its use of an XML domain-specific language to define tests, contexts to decouple entities, plugins for extensibility, and support for techniques like polymorphism, page objects, and data-driven testing. The document also covers how the platform has evolved over time and can be used to test itself.
Improving The Quality of Existing SoftwareSteven Smith
Presented at DevReach 2013.
As developers, most of our time is spent working on existing software. Sure, occasionally we get the chance to fire up a new Solution in Visual Studio, and that can be exciting. But after the first day, we find ourselves once more having to deal with the work we did yesterday. And today, we know more than we did yesterday, so there are things we’d do differently, if we had it to do over.
Over time, software rots. If we’re not diligent, our beautiful code can degrade into a worthless mess. Keeping our code in working condition is no different than changing the oil in our car – it’s preventive maintenance. In this session, Steve will look at some common places to look for signs of degradation in existing applications, and steps to take to improve the code. Examples will use C# and primarily ASP.NET.
Slides from the Selenium Clinic Tutorial from Eurostar 2012 hosted by Simon Stewart and Alan Richardson. The tutorial was awarded "Best Tutorial" at the conference.
The reference slides were excerpted from Alan Richardson's online WebDriver course hosted at Udemy.
http://www.udemy.com/selenium-2-webdriver-basics-with-java/
Introducing domain driven design - dogfood con 2018Steven Smith
DDD provides a set of patterns and practices for tackling complex business problems with software models. Learn the basics of DDD in this session, including several principles and patterns you can start using immediately even if your project hasn't otherwise embraced DDD. Examples will primarily use C#/.NET.
Improving the Design of Existing SoftwareSteven Smith
The document discusses improving the design of existing software by following principles like DRY, SOLID, and refactoring code using techniques such as extracting classes, methods, and interfaces. It emphasizes writing characterization tests to preserve existing behavior when refactoring, and improving code quality by reducing duplication, dependencies, and complexity over time through preventative maintenance and refactoring.
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Theo Jungeblut
All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation. This first session creates the foundation for the 2nd Clean Code presentation on Dependency Injection, as it explains expected base knowledge.
Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs. Writing clean code can significantly lower these costs. However, writing clean code also makes you more efficient during the initial development time and results in more stable code. You will be presented design patterns and best practices which will make you write better and more easily maintainable code, seeing code in a holistic way. You will learn how to apply them by using an existing implementation as the starting point of the presentation. Finally, patterns & practices benefits are explained.
This presentation is based on C# and Visual Studio 2012. However, the demonstrated patterns and practice can be applied to every other programming language too.
Arquillian: Helping web developers and QA get alongLukáš Fryč
Modern development practices include testing our Web applications as a fundamental part of the application development lifecycle. Web UIs though can be particularly difficult to test with basic tools. Arquillian is an award-winning integration testing framework and Selenium WebDriver is an outstanding tool for UI test automation. Together they offer a base for high-quality tests.
This session looks to the Arquillian Universe for help. Equipped with the Arquillian extensions - Drone, Graphene and Warp - we will show you tests that cover both client-side (REST) and server-rendered (JSF) web applications. With a single test it is now possible to assert state (both in the server and on the client) at arbitrary points within the request lifecycle!
We will look at current best practices for how to achieve a rapid turnaround when doing test development by minimizing the effort required to write tests, and thereby increase productivity and thus making these tests future-proof. Additionally we will show tools and techniques that provide a separation of concerns between test authors (developers) and test automators (QA). How to execute a single test in both arbitrary server containers as well as arbitrary client browsers. And how it can enable us to run test suites in constrained environments like cloud-based continuous integration providers.
How to cover your web pages with easy tests in Python using easy wrapper over selenium of Selenide style. What are the styles of test coverage? How to start automation on your project? Which tool to choose?
This is a presentation to correspondent workshop (in russian) happened to have place in Kiev, during "Black Tea Testing #8" testing event, organized by Cogniance (cogniance.com) and IT Labs (itlabs.net.ua).
See video (in russian) at https://youtu.be/m1lopvj4nNg
See code src at https://github.com/yashaka/easy-web-tests-python/
Testcontainers - Geekout EE 2017 presentationRichard North
Unit testing our code on the JVM is well catered for with a lot of great tools that are mature and reliable – things tend to just work. Integrated testing, however, is another matter. Any time we face a situation where we need to involve non-JVM elements in our tests, we’re faced with painful environment setup and repeatability issues. Testcontainers aims to make integrated tests a little less unpleasant, through the power of Docker. Databases, Web browsers – in fact anything available as a Docker image – can be made available as a component to use in our tests.
In this talk, we’ll go through the motivations for building Testcontainers, its features, as well as some examples of using it in practice for testing various types of components.
Improving the Quality of Existing SoftwareSteven Smith
The document discusses techniques for improving the quality of existing software, including reducing technical debt, following principles like DRY and SOLID, using characterization tests to preserve behavior during refactoring, and improving skills to write higher quality code faster. It covers topics like refactoring, test-driven development, dependency inversion, and design patterns. The goal is to maintain and enhance application code quality over time through refactoring and preventing technical debt.
Improving the Quality of Existing SoftwareSteven Smith
Given at DogFoodCon 2016 in Columbus, Ohio
As developers, most of our time is spent working on existing software – even if it’s just the software we wrote ourselves, yesterday. And over time, software rots. If were not diligent, our beautiful code can degrade into a worthless mess. Keeping our code in working condition is no different than changing the oil in our car “ its preventive maintenance. In this session, Steve will cover some common places to look for signs of degradation in existing applications, and describe the steps we can take to improve our code. Examples will use C# and primarily ASP.NET.
Improving the Quality of Existing Software - DevIntersection April 2016Steven Smith
How do you improve the quality of your existing software, while continuing to add value for your customers? What are some heuristics and code smells you can look for, and principles and patterns you can use to guide you, as you make your software better over time instead of worse? How can we improve our skills and techniques so that writing high quality software becomes our default, fastest way of working?
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
You will learn why naming is really difficult if done right, why coding and style guidelines are crucial, code structuring, exception handling and why other elements of coding often define the tipping point between success and failure of projects. Following the principles of software craftsmanship will allow you to end up with better maintainability and extensibility of your software and the success of the project in the end. All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation.
Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs. Writing clean code can significantly lower these costs. However, writing clean code also makes you more efficient during the initial development time and results in more stable code. You will be presented design patterns and best practices which will make you write better and more easily maintainable code, seeing code in a holistic way. You will learn how to apply them by using an existing implementation as the starting point of the presentation. Finally, patterns & practices benefits are explained.
This presentation is based on C# and Visual Studio 2012. However, the demonstrated patterns and practice can be applied to every other programming language too.
The Cowardly Test-o-Phobe's Guide To TestingTim Duckett
The document discusses testing iOS applications. It begins by addressing why testing can be scary and introduces test-driven development as an approach to make testing less scary. It then covers different tools for testing iOS apps, including frameworks for unit testing and UI testing. It emphasizes the importance of mocking and stubbing dependencies to isolate parts of the code for testing. The document also discusses approaches for testing network requests, such as using a tool called OHHTTPStubs to stub network responses from files. It concludes by encouraging testing user interfaces in code and using mocking/stubbing to handle dependencies.
Clan code is extremely essential to build scalable application which can be maintained quite easily and improved further
Slide was prepared with contribution to my colleague
and i thank them for the help!
Learn How to Unit Test Your Android Application (with Robolectric)Marakana Inc.
The document discusses the Android unit test framework Robolectric. It provides an overview of Robolectric, including how it works by using shadow objects to simulate the Android framework classes, allowing tests to run on a normal JVM. It also covers how to get started with Robolectric by using the sample project, and how to write tests by accessing shadow objects and dealing with classes that don't expose full state.
This document provides a guide to resources for learning about the Selenium testing tool. It lists 25 different resources organized into categories like documentation, videos, books, blogs, forums, meetups and more. These include the Selenium HQ website, wiki, blogs, mailing lists, online groups, conferences and more. The document aims to help beginners, intermediate and advanced users find relevant Selenium information.
Learn the best QA / Testing Tools, Automation Testing tools and techniques Online & Classroom Training from the industry experts at Magnitia IT.
https://www.magnitia.com/testing-courses.html
Projects Valhalla, Loom and GraalVM at JCon 2020Vadym Kazulkin
This document summarizes Projects Valhalla, Loom and GraalVM. Project Valhalla aims to introduce inline types (value types) to Java to improve performance by reducing memory usage and indirection. Project Loom introduces virtual threads and continuations to allow writing scalable and asynchronous code more easily. GraalVM is a high-performance polyglot virtual machine for Java and other languages.
It is always tough to test a complex API comprehensively. The additional level of complexity brings us to the question “How can we validate that our API is working as intended?”
In this talk I will explain how to use test driven development for APIs to solve this problem and even further how TDD can drive an API Design towards a more usable design. I will outline my practical approach with an implementation example based on django. And finally I will give you a brief summary of my lessons learned using this approach in customer projects.
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Alan Richardson
This document provides an overview of a half-day tutorial on building abstraction layers for web automation tests using Selenium WebDriver. The tutorial will cover common approaches to modeling web applications and constructing page object and other abstraction layers. Attendees will participate in exercises to experiment with different abstraction techniques using a sample todo list application. The session will discuss topics like page object design, element abstractions, domain objects, and component abstractions. Code examples demonstrating various abstraction implementations will also be presented and analyzed.
Generalization in Auto-Testing. How we put what we had into new Technological...SQALab
This document discusses generalization in test automation and the XML2Selenium test automation platform. It provides an overview of the platform's architecture, including its use of an XML domain-specific language to define tests, contexts to decouple entities, plugins for extensibility, and support for techniques like polymorphism, page objects, and data-driven testing. The document also covers how the platform has evolved over time and can be used to test itself.
Improving The Quality of Existing SoftwareSteven Smith
Presented at DevReach 2013.
As developers, most of our time is spent working on existing software. Sure, occasionally we get the chance to fire up a new Solution in Visual Studio, and that can be exciting. But after the first day, we find ourselves once more having to deal with the work we did yesterday. And today, we know more than we did yesterday, so there are things we’d do differently, if we had it to do over.
Over time, software rots. If we’re not diligent, our beautiful code can degrade into a worthless mess. Keeping our code in working condition is no different than changing the oil in our car – it’s preventive maintenance. In this session, Steve will look at some common places to look for signs of degradation in existing applications, and steps to take to improve the code. Examples will use C# and primarily ASP.NET.
Slides from the Selenium Clinic Tutorial from Eurostar 2012 hosted by Simon Stewart and Alan Richardson. The tutorial was awarded "Best Tutorial" at the conference.
The reference slides were excerpted from Alan Richardson's online WebDriver course hosted at Udemy.
http://www.udemy.com/selenium-2-webdriver-basics-with-java/
Introducing domain driven design - dogfood con 2018Steven Smith
DDD provides a set of patterns and practices for tackling complex business problems with software models. Learn the basics of DDD in this session, including several principles and patterns you can start using immediately even if your project hasn't otherwise embraced DDD. Examples will primarily use C#/.NET.
Improving the Design of Existing SoftwareSteven Smith
The document discusses improving the design of existing software by following principles like DRY, SOLID, and refactoring code using techniques such as extracting classes, methods, and interfaces. It emphasizes writing characterization tests to preserve existing behavior when refactoring, and improving code quality by reducing duplication, dependencies, and complexity over time through preventative maintenance and refactoring.
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Theo Jungeblut
All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation. This first session creates the foundation for the 2nd Clean Code presentation on Dependency Injection, as it explains expected base knowledge.
Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs. Writing clean code can significantly lower these costs. However, writing clean code also makes you more efficient during the initial development time and results in more stable code. You will be presented design patterns and best practices which will make you write better and more easily maintainable code, seeing code in a holistic way. You will learn how to apply them by using an existing implementation as the starting point of the presentation. Finally, patterns & practices benefits are explained.
This presentation is based on C# and Visual Studio 2012. However, the demonstrated patterns and practice can be applied to every other programming language too.
Arquillian: Helping web developers and QA get alongLukáš Fryč
Modern development practices include testing our Web applications as a fundamental part of the application development lifecycle. Web UIs though can be particularly difficult to test with basic tools. Arquillian is an award-winning integration testing framework and Selenium WebDriver is an outstanding tool for UI test automation. Together they offer a base for high-quality tests.
This session looks to the Arquillian Universe for help. Equipped with the Arquillian extensions - Drone, Graphene and Warp - we will show you tests that cover both client-side (REST) and server-rendered (JSF) web applications. With a single test it is now possible to assert state (both in the server and on the client) at arbitrary points within the request lifecycle!
We will look at current best practices for how to achieve a rapid turnaround when doing test development by minimizing the effort required to write tests, and thereby increase productivity and thus making these tests future-proof. Additionally we will show tools and techniques that provide a separation of concerns between test authors (developers) and test automators (QA). How to execute a single test in both arbitrary server containers as well as arbitrary client browsers. And how it can enable us to run test suites in constrained environments like cloud-based continuous integration providers.
How to cover your web pages with easy tests in Python using easy wrapper over selenium of Selenide style. What are the styles of test coverage? How to start automation on your project? Which tool to choose?
This is a presentation to correspondent workshop (in russian) happened to have place in Kiev, during "Black Tea Testing #8" testing event, organized by Cogniance (cogniance.com) and IT Labs (itlabs.net.ua).
See video (in russian) at https://youtu.be/m1lopvj4nNg
See code src at https://github.com/yashaka/easy-web-tests-python/
Testcontainers - Geekout EE 2017 presentationRichard North
Unit testing our code on the JVM is well catered for with a lot of great tools that are mature and reliable – things tend to just work. Integrated testing, however, is another matter. Any time we face a situation where we need to involve non-JVM elements in our tests, we’re faced with painful environment setup and repeatability issues. Testcontainers aims to make integrated tests a little less unpleasant, through the power of Docker. Databases, Web browsers – in fact anything available as a Docker image – can be made available as a component to use in our tests.
In this talk, we’ll go through the motivations for building Testcontainers, its features, as well as some examples of using it in practice for testing various types of components.
In this talk Aviel shares how they code, build, ship and monitor their apps at Chegg. From the modular project architecture, 3rd party tools and how they know and control what's going in production.
The document discusses Behavior Driven Development (BDD) using Cucumber. It describes Cucumber's basic structure using features, scenarios, and steps. Steps integrate specifications with code to protect against changes. Cucumber supports different programming languages for step definitions and provides HTML and JUnit XML reporting. It allows defining scenarios and examples in outline tables. Cucumber uses a green/red status to indicate test success/failure.
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfNCCOMMS
This document discusses Azure Functions and serverless computing. It provides an overview of Azure Functions, including how they can be used for scheduled tasks or triggered by events. It compares Azure Functions to Web Jobs and outlines pricing plans. The document also covers security options, local development, using bindings, and deployment. It demonstrates how to write a first Azure Function and discusses troubleshooting and next steps like durable functions.
Learning iOS and hunting NSZombies in 3 weeksCalvin Cheng
Language (programming language) wars are overrated.
As a professional/career software engineer, it is our job to learn fast, evolve and continually grow in the context of different languages and software paradigms.
Learning Objective-C and iOS cocoa touch framework isn't as scary as people purport it to be. Ignore the critics, trust in your own abilities and dive into Objective-C if you need to build a mobile app for your company. Today.
Design Patterns are not only cool but also bring years of collective wisdom to every level of developers. Since GoF, many books have been written and words shed, as well as many new concepts like Enterprise and Domain Design Patterns extended the coverage the Design Patterns, originally shared by the famous Gang of Four. Unlike the J2EE 1.4 era, Java EE provides easy and out of box implementations of many well known design patterns such as Singleton, Façade, Observer, Factory, Dependency Injection, Decorator, Data Access Patterns, MVC and even more. Many classical design patterns are actually just one annotation away from your project.
Breaking Dependencies to Allow Unit TestingSteven Smith
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
Presented at FalafelCON 2014, San Francisco, September 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014FalafelSoftware
Unit testing software can be difficult, especially when the software wasn't designed to be testable. Dependencies on infrastructure concerns and software we don't control are one of the biggest contributors to testing difficulty. In this session, you'll learn the difference between unit tests and other kinds of tests, how to recognize and invert dependencies, and how to unit test your code's interactions with these dependencies without testing the infrastructure itself.
Level Up Your Integration Testing With TestcontainersVMware Tanzu
The document discusses Testcontainers, a Java library that makes it easy to create lightweight, disposable Docker containers to support integration testing. Testcontainers allows developers to start containers for databases, browsers, and other services via simple annotations and eliminates the need to manage complex Docker configurations and container lifecycles manually. It integrates with JUnit and handles starting a new container before each test and cleaning it up afterwards, improving testing fidelity by mimicking production environments.
Clean Code - Design Patterns and Best Practices at Silicon Valley Code CampTheo Jungeblut
Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs.
Writing clean code can significantly lower these costs. However, writing clean code also makes you more efficient during the initial development time and results in more stable code.
You will be presented design patterns and best practices which will make you write better and more easily maintainable code, seeing code in a holistic way. You will learn how to apply them by using an existing implementation as the starting point of the presentation. Finally, patterns & practices benefits are explained. This presentation is based on C# and Visual Studio 2012.
However, the demonstrated patterns and practice can be applied to almost every other programming language too.
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...seleniumconf
Dan Cuellar discusses strategies for writing automated tests that are robust and maintainable in the face changing codebases and features. These include separating logical test actions from direct controller calls, centralizing site elements and logic, adding self-testing capabilities, consolidating product actions into abstracted libraries, and creating platform-agnostic test scripts. The goal is to design tests that can adapt easily without extensive rework when underlying systems evolve rapidly.
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to realityDaniel Gallego Vico
This presentation shows how to be a pragmatic Android programmer by showing real examples of applications/products developed in BQ attending to three important topics:
- Why and how to implement a pragmatic CLEAN architecture with a custom dependency injection framework and ReactiveX features.
- Why and how to implement unit, integration, view and smoke tests in every CLEAN layer and what tools should be used.
- Why and how to implement pragmatic Continuous
Development/Testing/Integration/Delivery by showing several tricks, plugins and snippets that you could use as a daily basis.
This document provides an overview of end-to-end testing with Protractor by summarizing various terminology, demonstrating example tests, and discussing continuous integration practices. It defines key Angular and testing concepts like directives, dependency injection, Jasmine, and WebDriver. Example tests are shown for a calculator app and a mock Facebook app. Continuous integration is discussed in the context of running Protractor tests within Docker containers as part of the software delivery pipeline.
Into The Box 2018 | Assert control over your legacy applicationsOrtus Solutions, Corp
This document discusses how to add tests to legacy code using the TestBox testing framework for ColdFusion applications. It defines unit testing and different types of tests like unit, integration, and end-to-end tests. TestBox allows writing automated tests for ColdFusion code and isolating dependencies using test doubles. The document outlines best practices for test-driven development including writing tests before code, using life cycle methods, and refactoring code without changing external behavior. Implementing a testing framework like TestBox helps assert control over legacy applications by adding tests and the ability to refactor code safely.
How to Build Your Own Test Automation Framework?Dmitry Buzdin
Even though there are plenty of open source tools on the market every company needs to put them together and create a test automation framework on top. Best practices of doing that are quite well-known in industry and it is important to learn them before building your own framework. We will go through the core building blocks of test automation frameworks and how they are playing together. You will learn how to assemble your test automation toolchain out of open source libraries and how to integrate them together. The session will be heavily biased towards Java platform.
Devoxx UK 2015: How Java EE has changed pattern implementationAlex Theedom
The implementation of traditional design patterns have changed in Java EE 7. By taking advantage of Java EE features such as CDI and the smart use of annotations, traditional design patterns can be implemented in a much cleaner and quicker way. With the use of code examples I will demonstrate how to implement some of the most commonly use design patterns in Java EE. Among the design patterns discuss there will be Factory, Singleton, Observer and Decorator.
DevOps Fest 2020. Alexey Golub. GitHub Actions in actionDevOps_Fest
GitHub released its new CI/CD platform called ""Actions"" on the 13th of November this year. Since then it was rumored to be the ""be-all, end-all"" of build automation tools for open source developers.
In this talk we'll look at what GitHub Actions offers us as a maintainer of an OSS project, what benefits (and drawbacks?) it has compared to established platforms such as AppVeyor, TravisCI, CircleCI, and how easy (or hard?) is it to get started today.
We'll also take a look at how you can author your own custom automation scenarios (i.e. actions) to create complex pipelines and see how that helps with maintainability.
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/1stYuc2.
Brennan Saeta covers aspects of Coursera’s architecture that enables them to rapidly build sophisticated features for their learning platform. Saeta discusses also their experience running containers in production, what works, what doesn’t, and why. He briefly touches upon container threat models, and how to architect a defense-in-depth strategy to mitigate both known and unknown vulnerabilities. Filmed at qconlondon.com.
Brennan Saeta is a Lead Infrastructure Engineer, leading the ‘Cour’ (core) group responsible for the development environment, core libraries, and the common infrastructure powering Coursera.
original (better quality) on https://docs.google.com/presentation/d/1bnwj8CrFGo5KekONYSeIHySdkoXZiewJxkHcZjXnzkQ/
slides from OpenDaylight Summit Oct 2016 Seattle
Reality-Driven Testing using TestContainersOleksii Holub
This document discusses using TestContainers to test against real dependencies rather than mocks or fakes. TestContainers allows setting up isolated Docker containers for testing that can be configured and used within tests. Using real dependencies provides more confidence than mocks but can be challenging. TestContainers makes it easy to test against services like databases and APIs in Docker containers, improving test quality while keeping tests fast and simple. The document demonstrates TestContainers and discusses isolation strategies and performance considerations.
CliWrap is a .NET library that provides a fluent interface and asynchronous API for executing command line processes. It addresses pitfalls in the System.Diagnostics.Process API related to deadlocks, race conditions, and inconsistent behavior across platforms. CliWrap provides abstractions for launching processes, redirecting streams, handling cancellation, and more. It is used by Microsoft, StackOverflow, and over 500 open source projects.
This document discusses expression trees in C#. It begins with an introduction to expression trees, which describe the structure of an expression. It then discusses how expression trees are represented in .NET using types deriving from System.Linq.Expressions.Expression. It provides examples of constructing expression trees manually using factory methods, and how lambda expression trees can be converted into delegates. The document also discusses optimizing reflection-heavy code using expression trees, implementing generic operators with expression trees, parsing DSLs into expression trees, obtaining expression trees from lambdas, and identifying type members using expression trees.
The document discusses expression trees in C#. It provides examples of constructing expression trees manually by creating expression tree nodes like ConstantExpression and MethodCallExpression. It also discusses parsing code into expression trees, optimizing reflection-heavy code using expression trees, building generic operators using expression trees, and inferring expression trees from code.
GitHub Actions is an automation platform for GitHub repositories that allows users to build workflows to automate software tasks. It was introduced in 2019 and is based on Azure Pipelines. Workflows are configured using YAML files and can be triggered by events like push commits, pull requests, or scheduled times. Actions, which are reusable code components, can be used in workflows and are sourced from the GitHub marketplace or created by users. GitHub Actions is free for public repositories and offers paid plans for private repositories.
Thorough introduction to language parsing in C#, overview of different approaches, and live-coding session that showcases how to build a working JSON parser using Sprache
Carrer goals.pptx and their importance in real lifeartemacademy2
Career goals serve as a roadmap for individuals, guiding them toward achieving long-term professional aspirations and personal fulfillment. Establishing clear career goals enables professionals to focus their efforts on developing specific skills, gaining relevant experience, and making strategic decisions that align with their desired career trajectory. By setting both short-term and long-term objectives, individuals can systematically track their progress, make necessary adjustments, and stay motivated. Short-term goals often include acquiring new qualifications, mastering particular competencies, or securing a specific role, while long-term goals might encompass reaching executive positions, becoming industry experts, or launching entrepreneurial ventures.
Moreover, having well-defined career goals fosters a sense of purpose and direction, enhancing job satisfaction and overall productivity. It encourages continuous learning and adaptation, as professionals remain attuned to industry trends and evolving job market demands. Career goals also facilitate better time management and resource allocation, as individuals prioritize tasks and opportunities that advance their professional growth. In addition, articulating career goals can aid in networking and mentorship, as it allows individuals to communicate their aspirations clearly to potential mentors, colleagues, and employers, thereby opening doors to valuable guidance and support. Ultimately, career goals are integral to personal and professional development, driving individuals toward sustained success and fulfillment in their chosen fields.
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsRosie Wells
Insight: In a landscape where traditional narrative structures are giving way to fragmented and non-linear forms of storytelling, there lies immense potential for creativity and exploration.
'Collapsing Narratives: Exploring Non-Linearity' is a micro report from Rosie Wells.
Rosie Wells is an Arts & Cultural Strategist uniquely positioned at the intersection of grassroots and mainstream storytelling.
Their work is focused on developing meaningful and lasting connections that can drive social change.
Please download this presentation to enjoy the hyperlinks!
This presentation by OECD, OECD Secretariat, was made during the discussion “Artificial Intelligence, Data and Competition” held at the 143rd meeting of the OECD Competition Committee on 12 June 2024. More papers and presentations on the topic can be found at oe.cd/aicomp.
This presentation was uploaded with the author’s consent.
This presentation by Thibault Schrepel, Associate Professor of Law at Vrije Universiteit Amsterdam University, was made during the discussion “Artificial Intelligence, Data and Competition” held at the 143rd meeting of the OECD Competition Committee on 12 June 2024. More papers and presentations on the topic can be found at oe.cd/aicomp.
This presentation was uploaded with the author’s consent.
This presentation by Yong Lim, Professor of Economic Law at Seoul National University School of Law, was made during the discussion “Artificial Intelligence, Data and Competition” held at the 143rd meeting of the OECD Competition Committee on 12 June 2024. More papers and presentations on the topic can be found at oe.cd/aicomp.
This presentation was uploaded with the author’s consent.
This presentation by OECD, OECD Secretariat, was made during the discussion “Competition and Regulation in Professions and Occupations” held at the 77th meeting of the OECD Working Party No. 2 on Competition and Regulation on 10 June 2024. More papers and presentations on the topic can be found at oe.cd/crps.
This presentation was uploaded with the author’s consent.
XP 2024 presentation: A New Look to Leadershipsamililja
Presentation slides from XP2024 conference, Bolzano IT. The slides describe a new view to leadership and combines it with anthro-complexity (aka cynefin).
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...SkillCertProExams
• For a full set of 760+ questions. Go to
https://skillcertpro.com/product/databricks-certified-data-engineer-associate-exam-questions/
• SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
• It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
• SkillCertPro updates exam questions every 2 weeks.
• You will get life time access and life time free updates
• SkillCertPro assures 100% pass guarantee in first attempt.
This presentation by Professor Alex Robson, Deputy Chair of Australia’s Productivity Commission, was made during the discussion “Competition and Regulation in Professions and Occupations” held at the 77th meeting of the OECD Working Party No. 2 on Competition and Regulation on 10 June 2024. More papers and presentations on the topic can be found at oe.cd/crps.
This presentation was uploaded with the author’s consent.
This presentation by Nathaniel Lane, Associate Professor in Economics at Oxford University, was made during the discussion “Pro-competitive Industrial Policy” held at the 143rd meeting of the OECD Competition Committee on 12 June 2024. More papers and presentations on the topic can be found at oe.cd/pcip.
This presentation was uploaded with the author’s consent.
4. Speaker: Alexey Golub @Tyrrrz
Clarification
Unit testing is not inherently bad, but the practices & beliefs surrounding it
often lead to cargo cult mentality
Some subjects in the talk may be opinionated and come from my own
experience, which might not represent yours
I will rely on “classic” definitions, where…
• Unit tests target smallest separable parts of code
• End-to-end tests target the application boundaries
• Integration tests target everything in-between
10. • Unit tests achieve isolation by stubbing dependencies
• Unit tests don’t cover integrations between units
• Unit tests mostly avoid exercising effectful code
• Unit tests are primarily useful to verify business logic
Speaker: Alexey Golub @Tyrrrz
11. Speaker: Alexey Golub @Tyrrrz
public class LocationProvider : IDisposable
{
private readonly HttpClient _httpClient = new HttpClient();
// Gets location by query
public async Task<Location> GetLocationAsync(string locationQuery) { /* ... */ }
// Gets current location by IP
public async Task<Location> GetLocationAsync() { /* ... */ }
public void Dispose() => _httpClient.Dispose();
}
Design is fine, but
not unit-testable
public class SolarCalculator : IDiposable
{
private readonly LocationProvider _locationProvider = new LocationProvider();
// Gets solar times for current location and specified date
public async Task<SolarTimes> GetSolarTimesAsync(DateTimeOffset date) { /* //. // }
public void Dispose() /> _locationProvider.Dispose();
}
12. Speaker: Alexey Golub @Tyrrrz
public interface ILocationProvider
{
Task<Location> GetLocationAsync(string locationQuery);
Task<Location> GetLocationAsync();
}
public class LocationProvider : ILocationProvider
{
private readonly HttpClient _httpClient;
public LocationProvider(HttpClient httpClient) => _httpClient = httpClient;
public async Task<Location> GetLocationAsync(string locationQuery) { /* ... */ }
public async Task<Location> GetLocationAsync() { /* ... */ }
}
public interface ISolarCalculator
{
Task<SolarTimes> GetSolarTimesAsync(DateTimeOffset date);
}
public class SolarCalculator : ISolarCalculator
{
private readonly ILocationProvider _locationProvider;
public SolarCalculator(ILocationProvider locationProvider) => _locationProvider = locationProvider;
public async Task<SolarTimes> GetSolarTimesAsync(DateTimeOffset date) { /* ... */ }
}
Isolation through
dependency
inversion
13. Design influence
• Isolation comes at the expense of fragmentation
• Objects no longer encapsulate their dependencies
• Abstractions for the sake of testing, not polymorphism
• Design driven by testability, rather than domain
Speaker: Alexey Golub @Tyrrrz
14. Speaker: Alexey Golub @Tyrrrz
public class SolarCalculatorTests
{
[Fact]
public async Task GetSolarTimesAsync_ForKyiv_ReturnsCorrectSolarTimes()
{
// Arrange
var location = new Location(50.45, 30.52);
var date = new DateTimeOffset(2019, 11, 04, 00, 00, 00, TimeSpan.FromHours(+2));
var expectedSolarTimes = new SolarTimes(
new TimeSpan(06, 55, 00),
new TimeSpan(16, 29, 00)
);
var locationProvider = Mock.Of<ILocationProvider>(lp =>
lp.GetLocationAsync() == Task.FromResult(location)
);
var solarCalculator = new SolarCalculator(locationProvider);
// Act
var solarTimes = await solarCalculator.GetSolarTimesAsync(date);
// Assert
solarTimes.Should().BeEquivalentTo(expectedSolarTimes);
}
}
Implementation-
aware testing
Tight coupling to a
specific class/method
15. Consider the drawbacks
• Unit tests rely on implementation details
Speaker: Alexey Golub @Tyrrrz
Unit
Dep A
Dep B
Dep C
Which method does it use?
How is it used?
When does it call it?
How many times does it call it?
16. Consider the drawbacks
• Unit tests often lead to more complicated design
Speaker: Alexey Golub @Tyrrrz
Unit Unit
Unit
Unit Unit
Unit
17. Consider the drawbacks
• Unit tests can get quite expensive
Speaker: Alexey Golub @Tyrrrz
UnitDep
Mock
A
Mock
B
Mock
C
18. Consider the drawbacks
• Unit tests are limited in purpose
Speaker: Alexey Golub @Tyrrrz
Payroll
System
CRUD
application
Business logic (%)
19. Consider the drawbacks
• Unit tests don’t exercise user behavior
Speaker: Alexey Golub @Tyrrrz
User
API
UI
CLI
Unit
Unit
Unit
Unit
25. Integration tests are not slow
• Just because they can be, doesn’t mean they should be
• Technologies make things easier
• Architecture dictates testability
Speaker: Alexey Golub @Tyrrrz
26. Return on investment is not linear
• Isolation isn’t free
• Higher-level tests are often cheaper
• Cheap & fast tests aren’t automatically valuable
Speaker: Alexey Golub @Tyrrrz
27. Business logic is not a constant
• Value of unit testing is contingent on the amount of business logic
• Modern software contains a lot of “glue” code
• Depending on the project, the pyramid may be misleading
Speaker: Alexey Golub @Tyrrrz
30. Speaker: Alexey Golub @Tyrrrz
Component
System
Confidence
(value)
User
Systemboundary
Unit level End-to-end levelIntegration scope
31. Speaker: Alexey Golub @Tyrrrz
User needs to be able get solar times for their location
User needs to be able get solar times during periods of midnight sun
User needs to be able get solar times even if their location cannot be determined
Functional requirements
32. Speaker: Alexey Golub @Tyrrrz
public class SolarTimesSpecs
{
[Fact]
public async Task User_can_get_solar_times_automatically_for_their_location() { /* //. // }
[Fact]
public async Task User_can_get_solar_times_during_periods_of_midnight_sun() { /* //. // }
[Fact]
public async Task User_can_get_solar_times_if_their_location_cannot_be_determined() { /* //. // }
}
Functional tests
33. Speaker: Alexey Golub @Tyrrrz
Functional tests Powered by xUnit’s
test display options
✓ Live documentation
✓ Human-readable test
names
✓ No dependency on code
structure
34. Functional requirements can be…
• Formal
Software specification documents, user stories, etc.
• Informal
JIRA tickets, readme, API documentation, usage instructions, assumed, etc.
Every software has them, in one form or the other (yes, even yours)
Speaker: Alexey Golub @Tyrrrz
35. Speaker: Alexey Golub @Tyrrrz
Guidelines
• Write tests that are as highly integrated as possible ⚙️
• Keep their speed, complexity, and stability acceptable 🚀
• Partition tests based on threads of behavior 🖱️
• Test suite should not mirror code structure 🔗
37. public class LocationProvider
{
private readonly HttpClient _httpClient;
public LocationProvider(HttpClient httpClient) />
_httpClient = httpClient;
public async Task<Location> GetLocationAsync(IPAddress ip)
{
// If IP is local, just don't pass anything (useful when running on localhost)
var ipFormatted = !ip.IsLocal() ? ip.MapToIPv4().ToString() : "";
var json = await _httpClient.GetJsonAsync($"http://ip-api.com/json/{ipFormatted}");
var latitude = json.GetProperty("lat").GetDouble();
var longitude = json.GetProperty("lon").GetDouble();
return new Location
{
Latitude = latitude,
Longitude = longitude
};
}
}
Speaker: Alexey Golub @Tyrrrz
38. public class SolarCalculator
{
private readonly LocationProvider _locationProvider;
public SolarCalculator(LocationProvider locationProvider) />
_locationProvider = locationProvider;
private static TimeSpan CalculateSolarTimeOffset(Location location, DateTimeOffset instant,
double zenith, bool isSunrise)
{
/* //. //
}
public async Task<SolarTimes> GetSolarTimesAsync(IPAddress ip, DateTimeOffset date)
{
var location = await _locationProvider.GetLocationAsync(ip);
var sunriseOffset = CalculateSolarTimeOffset(location, date, 90.83, true);
var sunsetOffset = CalculateSolarTimeOffset(location, date, 90.83, false);
var sunrise = date.ResetTimeOfDay().Add(sunriseOffset);
var sunset = date.ResetTimeOfDay().Add(sunsetOffset);
return new SolarTimes
{
Sunrise = sunrise,
Sunset = sunset
};
}
}
Speaker: Alexey Golub @Tyrrrz
39. [ApiController, Route("solartimes")]
public class SolarTimeController : ControllerBase
{
private readonly SolarCalculator _solarCalculator;
private readonly CachingLayer _cachingLayer;
public SolarTimeController(SolarCalculator solarCalculator, CachingLayer cachingLayer)
{
_solarCalculator = solarCalculator;
_cachingLayer = cachingLayer;
}
[HttpGet("by_ip")]
public async Task<IActionResult> GetByIp(DateTimeOffset? date)
{
var ip = HttpContext.Connection.RemoteIpAddress;
var cacheKey = $"{ip},{date}";
var cachedSolarTimes = await _cachingLayer.TryGetAsync<SolarTimes>(cacheKey);
if (cachedSolarTimes != null)
return Ok(cachedSolarTimes);
var solarTimes = await _solarCalculator.GetSolarTimesAsync(ip, date ?? DateTimeOffset.Now);
await _cachingLayer.SetAsync(cacheKey, solarTimes);
return Ok(solarTimes);
}
}
Speaker: Alexey Golub @Tyrrrz
40. public class CachingLayer
{
private readonly IConnectionMultiplexer _redis;
public CachingLayer(IConnectionMultiplexer connectionMultiplexer) =>
_redis = connectionMultiplexer;
public async Task<T> TryGetAsync<T>(string key) where T : class
{
var result = await _redis.GetDatabase().StringGetAsync(key);
if (result.HasValue)
return JsonSerializer.Deserialize<T>(result.ToString());
return null;
}
public async Task SetAsync<T>(string key, T obj) where T : class =>
await _redis.GetDatabase().StringSetAsync(key, JsonSerializer.Serialize(obj));
}
Speaker: Alexey Golub @Tyrrrz
41. public class Startup
{
// //.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(o /> o.EnableEndpointRouting = false);
services.AddSingleton<IConnectionMultiplexer>(
ConnectionMultiplexer.Connect(GetRedisConnectionString()));
services.AddSingleton<CachingLayer>();
services.AddHttpClient<LocationProvider>();
services.AddTransient<SolarCalculator>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseMvcWithDefaultRoute();
}
}
Speaker: Alexey Golub @Tyrrrz
42. public class FakeApp : IDisposable
{
private readonly WebApplicationFactory<Startup> _appFactory;
public HttpClient Client { get; }
public FakeApp()
{
_appFactory = new WebApplicationFactory<Startup>();
Client = _appFactory.CreateClient();
}
public void Dispose()
{
Client.Dispose();
_appFactory.Dispose();
}
}
Speaker: Alexey Golub @Tyrrrz
Runs the entire HTTP
pipeline in-memory
Get a client to talk to
our app
43. public class RedisFixture : IAsyncLifetime
{
private string _containerId;
public async Task InitializeAsync()
{
var result = await Cli.Wrap("docker")
.WithArguments("run -d -p 6379:6379 redis")
.ExecuteBufferedAsync();
_containerId = result.StandardOutput.Trim();
}
public async Task ResetAsync() />
await Cli.Wrap("docker")
.WithArguments($"exec {_containerId} redis-cli FLUSHALL")
.ExecuteAsync();
public async Task DisposeAsync() />
await Cli.Wrap("docker")
.WithArguments($"container kill {_containerId}")
.ExecuteAsync();
}
Speaker: Alexey Golub @Tyrrrz
Ideally should bind
to a random port
Can also use:
• Docker.NET
• .NET TestContainers
44. public class SolarTimeSpecs : IClassFixture<RedisFixture>, IAsyncLifetime
{
private readonly RedisFixture _redisFixture;
public SolarTimeSpecs(RedisFixture redisFixture) =>
_redisFixture = redisFixture;
public async Task InitializeAsync() => await _redisFixture.ResetAsync();
[Fact]
public async Task User_can_get_solar_times_for_their_location_by_ip()
{
// Arrange
using var app = new FakeApp();
// Act
var response = await app.Client.GetStringAsync("/solartimes/by_ip");
var solarTimes = JsonSerializer.Deserialize<SolarTimes>(response);
// Assert
solarTimes.Sunset.Should().BeWithin(TimeSpan.FromDays(1)).After(solarTimes.Sunrise);
solarTimes.Sunrise.Should().BeCloseTo(DateTimeOffset.Now, TimeSpan.FromDays(1));
solarTimes.Sunset.Should().BeCloseTo(DateTimeOffset.Now, TimeSpan.FromDays(1));
}
}
Speaker: Alexey Golub @Tyrrrz
Redis is reset
between tests
Requirement-driven test
Property-based assertions
45. public class FakeIpStartupFilter : IStartupFilter
{
public IPAddress Ip { get; set; } = IPAddress.Parse("::1");
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> nextFilter)
{
return app =>
{
app.Use(async (ctx, next) =>
{
ctx.Connection.RemoteIpAddress = Ip;
await next();
});
nextFilter(app);
};
}
}
Speaker: Alexey Golub @Tyrrrz
46. public class FakeApp : IDisposable
{
private readonly WebApplicationFactory<Startup> _appFactory;
private readonly FakeIpStartupFilter _fakeIpStartupFilter = new FakeIpStartupFilter();
public HttpClient Client { get; }
public IPAddress ClientIp
{
get => _fakeIpStartupFilter.Ip;
set => _fakeIpStartupFilter.Ip = value;
}
public FakeApp()
{
_appFactory = new WebApplicationFactory<Startup>().WithWebHostBuilder(o =>
{
o.ConfigureServices(s =>
{
s.AddSingleton<IStartupFilter>(_fakeIpStartupFilter);
});
});
Client = _appFactory.CreateClient();
}
// ...
}
Speaker: Alexey Golub @Tyrrrz
Inject fake IP provider
into pipeline
47. [Fact]
public async Task User_can_get_solar_times_for_their_location_by_ip()
{
// Arrange
using var app = new FakeApp
{
ClientIp = IPAddress.Parse("20.112.101.1")
};
var date = new DateTimeOffset(2020, 07, 03, 0, 0, 0, TimeSpan.FromHours(-5));
var expectedSunrise = new DateTimeOffset(2020, 07, 03, 05, 20, 37, TimeSpan.FromHours(-5));
var expectedSunset = new DateTimeOffset(2020, 07, 03, 20, 28, 54, TimeSpan.FromHours(-5));
// Act
var query = new QueryBuilder
{
{"date", date.ToString("O", CultureInfo.InvariantCulture)}
};
var response = await app.Client.GetStringAsync($"/solartimes/by_ip{query}");
var solarTimes = JsonSerializer.Deserialize<SolarTimes>(response);
// Assert
solarTimes.Sunrise.Should().BeCloseTo(expectedSunrise, TimeSpan.FromSeconds(1));
solarTimes.Sunset.Should().BeCloseTo(expectedSunset, TimeSpan.FromSeconds(1));
}
Speaker: Alexey Golub @Tyrrrz
Strict assertions
48. Speaker: Alexey Golub @Tyrrrz
✓ No mocks
✓ Real infrastructural dependencies
✓ Full HTTP pipeline
✓ High confidence
✓ Reasonable cost & speed
49. Speaker: Alexey Golub @Tyrrrz
The goal is not to cover everything end-to-end,
but to gain the highest return on investment
If you can test at the highest level, do it.
If not, reduce scope until the results are acceptable.
Confidence
Usability
50. Summary
1. Think critically and challenge best practices
2. Don’t rely on the test pyramid too much
3. Separate tests by functionality, rather than by classes or scope
4. Aim for highest level of integration with reasonable cost, speed, reliability
5. Avoid sacrificing software design for testability
6. Consider mocking only as a last resort
Speaker: Alexey Golub @Tyrrrz
51. Resources
• Unit Testing is Overrated (Alexey Golub)
https://tyrrrz.me/blog/unit-testing-is-overrated
• Write tests. Not too many. Mostly integration (Kent C. Dodds)
https://kentcdodds.com/blog/write-tests
• Mocking is a Code Smell (Eric Elliott)
https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70c90a6a
• Test-induced design damage (David Heinemeier Hansson)
https://dhh.dk/2014/test-induced-design-damage.html
Speaker: Alexey Golub @Tyrrrz