Property Based Testing is an process to build robust systems.
It facilitates a deeper understanding of the system under test. It can be used on any testing level: unit, integration or functional.
The presentation introduces how Property Based Testing works, how to use it with PHPUnit, and in what way it differentiates from example based tests.
It talks about strategies to find good properties to check for.
This presentation was built for the Meet-Magento conference 2020 in Mumbai.
Beyond xUnit example-based testing: property-based testing with ScalaCheckFranklin Chen
Test-Driven Development has become deservedly popular in the past decade, with easy-to-use xUnit unit testing frameworks leading the way toward encouraging developers to write tests. But xUnit has limitations: how does one know one has written enough test cases for a desired behavior? And what if the behavior is conditional on other behavior? Property-based testing, first popularized for Haskell with the QuickCheck library, but available now for other languages as well, offers a powerful addition to one's testing toolkit.
I will discuss the concepts of property-based testing and illustrate them concretely using ScalaCheck for Scala, and point toward similar test frameworks in other languages.
(Unit) Testing in Emberjs – Munich Ember.js Meetup July 2014istefo
This is a short talk given at the Ember.js Munich July Meetup. It briefly explains the basics of unit testing in Ember.js and gives some examples and details
Given that the database, as the canonical repository of data, is the most important part of many applications, why is it that we don't write database unit tests? This talk promotes the practice of implementing tests to directly test the schema, storage, and functionality of databases.
Property Based Testing is an process to build robust systems.
It facilitates a deeper understanding of the system under test. It can be used on any testing level: unit, integration or functional.
The presentation introduces how Property Based Testing works, how to use it with PHPUnit, and in what way it differentiates from example based tests.
It talks about strategies to find good properties to check for.
This presentation was built for the Meet-Magento conference 2020 in Mumbai.
Beyond xUnit example-based testing: property-based testing with ScalaCheckFranklin Chen
Test-Driven Development has become deservedly popular in the past decade, with easy-to-use xUnit unit testing frameworks leading the way toward encouraging developers to write tests. But xUnit has limitations: how does one know one has written enough test cases for a desired behavior? And what if the behavior is conditional on other behavior? Property-based testing, first popularized for Haskell with the QuickCheck library, but available now for other languages as well, offers a powerful addition to one's testing toolkit.
I will discuss the concepts of property-based testing and illustrate them concretely using ScalaCheck for Scala, and point toward similar test frameworks in other languages.
(Unit) Testing in Emberjs – Munich Ember.js Meetup July 2014istefo
This is a short talk given at the Ember.js Munich July Meetup. It briefly explains the basics of unit testing in Ember.js and gives some examples and details
Given that the database, as the canonical repository of data, is the most important part of many applications, why is it that we don't write database unit tests? This talk promotes the practice of implementing tests to directly test the schema, storage, and functionality of databases.
Why it is profitable to use static analysis, how can it solves problems for developers, testing, security researches and quality managers.
This session gives overview of static analysis - what is it for, what problems it solves, overview of commercial and free tools available as eclipse plugins (for JDT and CDT), how to adapt it for the organization to help developers.
When transitioning to functional programming as an already experienced developer in the imperative arts, one important skill fundamental to my technical maturity was thinking in terms of the properties of the systems I was building.
From modeling application domain constraints to testing distributed systems at scale in production, I found that thinking in properties can help you and your team build more sustainable systems.
Property-based testing provides a launchpad to discover and practice this mental model in your software development activities.
This session is for developers starting to exploit property-based testing from beginner to intermediate level and will:
- quickly review property-based testing
- identify common pitfalls with property-based testing alone
- suggest how to combine with other techniques and approaches to avoid their pitfalls
- illustrate think in properties so you can employ property-based “tests” at all phases of development
Limited exposure to the idea of property-based testing is desirable but not required. Code examples will be in Haskell.
Hamcrest is a library for creating matchers for usage in unit tests, mocks and UI validation. This talk gives a brief introduction to using and writing Hamcrest matchers.
The topics covered:
* Basic introduction to Hamcrest
* Using Matchers in assertions
* Using Matchers with Mockito
* Writing custom matchers
* Ad-hoc matchers
Developer testing 101: Become a Testing FanaticLB Denker
In this workshop we will cover the methodologies and three basic levels of testing, then we will deep dive into how to use PHPUnit to achieve developer testing. The tests may not be the prettiest, most robust, or efficient, but you should leave the course with the ability and confidence to write tests for your code.
Topics include: xUnit framework basics and workflows, test classification, asserts, data driven testing, and an introduction to mocking.
This is a beginner course, but seasoned veterans may discover features they never knew.
Agile teams know that defects are a drag. Literally! The effort to fix defects bottlenecks the pipeline and busts the sprint. And when defects are reported in production, things really bog down. Looking for a better way?
Model-driven testing offers a systematic way to answer some important questions. Such as “Are my tests good enough?” And “How many tests do I need?” This presentation shows how to use open source model-driven testing tools to quickly create small but powerful test suites.
JUnit is the de facto standard in Java testing. Yet many advanced JUnit features are little known and poorly understood. This session reviews some lesser-known features of JUnit, along with a few associated libraries, that can make your unit tests more powerful, expressive, and fun. The session is intended for Java developers, lead developers, and architects trying to introduce good testing practices into their teams.
Developer testing 201: When to Mock and When to IntegrateLB Denker
This workshop is for those who know how to write developer tests in PHPUnit. This workshop will expand upon that knowledge and further emphasize the difference between unit testing and integration testing. We will cover better tools and techniques for integration testing with databases and external services, and we will cover advanced mocking techniques to maintain a more fast and robust test suite.
Topics include: DBUnit, PHPUnit Mocks, Mockery, vfsStream
This course requires prior experience with PHPUnit or the 'Developer Testing 101: Become a Testing Fanatic' course.
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...Andrzej Jóźwiak
Finding edge cases and hidden bugs is hard for a fixed test data. It would be nice to think about tests as proofs, where certain properties of our code would be tested against generated sets of data. Is this possible? Can a framework prepare test data for us and find examples that do not work?
During this talk, we will explore a technique called Property-based testing (PBT) and how to apply it in our day to day work in Java. We will look how to build good properties and check few non academic examples of properties.
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTElena Laskavaia
Presentation about code analysis framework for CDT which is C/C++ IDE based on Eclipse. How to write a good static analysis tool? How to integrate right where develop introduces bugs? Catch bugs as you type!
This presentation is about the following points ,
What is synchronization,
Methods to configure synchronization,
Test setting method,
Wait method,
WaitProperty method,
Exist method,
Sync method,
Starting unit testing on a project can seem like a daunting task, and earning team and leadership buy-in can be challenging. We'll walk-through setup with composer, creating the first test, restructuring existing classes with dependency injection to allow unit testing, and releasing code confidently with test coverage. We'll also discuss overcoming common biases, unit testing challenges, and shortcomings of unit testing.
Watch the presentation at https://www.youtube.com/watch?v=6v4_bEajDUk
Why it is profitable to use static analysis, how can it solves problems for developers, testing, security researches and quality managers.
This session gives overview of static analysis - what is it for, what problems it solves, overview of commercial and free tools available as eclipse plugins (for JDT and CDT), how to adapt it for the organization to help developers.
When transitioning to functional programming as an already experienced developer in the imperative arts, one important skill fundamental to my technical maturity was thinking in terms of the properties of the systems I was building.
From modeling application domain constraints to testing distributed systems at scale in production, I found that thinking in properties can help you and your team build more sustainable systems.
Property-based testing provides a launchpad to discover and practice this mental model in your software development activities.
This session is for developers starting to exploit property-based testing from beginner to intermediate level and will:
- quickly review property-based testing
- identify common pitfalls with property-based testing alone
- suggest how to combine with other techniques and approaches to avoid their pitfalls
- illustrate think in properties so you can employ property-based “tests” at all phases of development
Limited exposure to the idea of property-based testing is desirable but not required. Code examples will be in Haskell.
Hamcrest is a library for creating matchers for usage in unit tests, mocks and UI validation. This talk gives a brief introduction to using and writing Hamcrest matchers.
The topics covered:
* Basic introduction to Hamcrest
* Using Matchers in assertions
* Using Matchers with Mockito
* Writing custom matchers
* Ad-hoc matchers
Developer testing 101: Become a Testing FanaticLB Denker
In this workshop we will cover the methodologies and three basic levels of testing, then we will deep dive into how to use PHPUnit to achieve developer testing. The tests may not be the prettiest, most robust, or efficient, but you should leave the course with the ability and confidence to write tests for your code.
Topics include: xUnit framework basics and workflows, test classification, asserts, data driven testing, and an introduction to mocking.
This is a beginner course, but seasoned veterans may discover features they never knew.
Agile teams know that defects are a drag. Literally! The effort to fix defects bottlenecks the pipeline and busts the sprint. And when defects are reported in production, things really bog down. Looking for a better way?
Model-driven testing offers a systematic way to answer some important questions. Such as “Are my tests good enough?” And “How many tests do I need?” This presentation shows how to use open source model-driven testing tools to quickly create small but powerful test suites.
JUnit is the de facto standard in Java testing. Yet many advanced JUnit features are little known and poorly understood. This session reviews some lesser-known features of JUnit, along with a few associated libraries, that can make your unit tests more powerful, expressive, and fun. The session is intended for Java developers, lead developers, and architects trying to introduce good testing practices into their teams.
Developer testing 201: When to Mock and When to IntegrateLB Denker
This workshop is for those who know how to write developer tests in PHPUnit. This workshop will expand upon that knowledge and further emphasize the difference between unit testing and integration testing. We will cover better tools and techniques for integration testing with databases and external services, and we will cover advanced mocking techniques to maintain a more fast and robust test suite.
Topics include: DBUnit, PHPUnit Mocks, Mockery, vfsStream
This course requires prior experience with PHPUnit or the 'Developer Testing 101: Become a Testing Fanatic' course.
Property based tests and where to find them - Andrzej Jóźwiak - TomTom Webina...Andrzej Jóźwiak
Finding edge cases and hidden bugs is hard for a fixed test data. It would be nice to think about tests as proofs, where certain properties of our code would be tested against generated sets of data. Is this possible? Can a framework prepare test data for us and find examples that do not work?
During this talk, we will explore a technique called Property-based testing (PBT) and how to apply it in our day to day work in Java. We will look how to build good properties and check few non academic examples of properties.
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTElena Laskavaia
Presentation about code analysis framework for CDT which is C/C++ IDE based on Eclipse. How to write a good static analysis tool? How to integrate right where develop introduces bugs? Catch bugs as you type!
This presentation is about the following points ,
What is synchronization,
Methods to configure synchronization,
Test setting method,
Wait method,
WaitProperty method,
Exist method,
Sync method,
Starting unit testing on a project can seem like a daunting task, and earning team and leadership buy-in can be challenging. We'll walk-through setup with composer, creating the first test, restructuring existing classes with dependency injection to allow unit testing, and releasing code confidently with test coverage. We'll also discuss overcoming common biases, unit testing challenges, and shortcomings of unit testing.
Watch the presentation at https://www.youtube.com/watch?v=6v4_bEajDUk
One of the biggest problems of software projects is that, while the practice of software development is commonly thought of as engineering, it is inherently a creative discipline; hence, many things about it are hard to measure. While simple yardsticks like test coverage and cyclomatic complexity are important for code quality, what other metrics can we apply to answer questions about our code? What coding conventions or development practices can we implement to make our code easier to measure? We'll take a tour through some processes and tools you can implement to begin improving code quality in your team or organization, and see what a difference it makes to long-term project maintainability. More importantly, we'll look at how we can move beyond today's tools to answer higher-level questions of code quality. Can 'good code' be quantified?
One of the biggest problems of software projects is that, while the practice of software development is commonly thought of as engineering, it is inherently a creative discipline; hence, many things about it are hard to measure. While simple yardsticks like test coverage and cyclomatic complexity are important for code quality, what other metrics can we apply to answer questions about our code? What coding conventions or development practices can we implement to make our code easier to measure? We'll take a tour through some processes and tools you can implement to begin improving code quality in your team or organization, and see what a difference it makes to long-term project maintainability. More importantly, we'll look at how we can move beyond today's tools to answer higher-level questions of code quality. Can 'good code' be quantified?
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
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.
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.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
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.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
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.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
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.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
4. Introduction
Agile manifesto emphasizes
- Frequent delivery
- Consistent development
pace
- Accommodating
requirements change
- Working software
- Customer satisfaction
5. Introduction
Agile manifesto emphasizes
- Frequent delivery
- Consistent development
pace
- Accommodating
requirements change
- Working software
- Customer satisfaction
6. Software bugs cost the U.S.
economy $59.5 billion
annually. More than a third
of this cost could be
avoided, if better software
testing was performed
(NIST, 2002)
The flipside
7. Software Fail Watch: 2016 in Review
https://www.tricentis.com/resource-assets/software-fail-
watch-2016/
8. During 2016, Raygun’s crash and error
reporting software ingested 7.7 billion
errors in total, which averages ~21
million per day.
Some of larger customers sent 50 million
crashes per month.
10. Software testing verifies SUT (system-under-test)
• meets the requirements that guided its design
and development
• responds correctly to all kinds of inputs
• performs its functions within an acceptable
time,
• is sufficiently usable
• can be installed and run in its intended
environments, and
• achieves the general result its stakeholders
desire.
11. Automated tests
• By far the most commonly
used approach to ensure
software quality
• Easily cover base flows and
edge cases in requirements
• Can be run unattended and
on schedule, can verify
something manual testing
can’t (e.g. load test)
• Easy to maintain* and
expand
12. Automated testing drawbacks
• Initial investment - can add up
to 50% of development time
• Writing tests upfront as best
practices suggest is not
possible in most of the cases
• Tests failures do not always
give 100% confidence there are
problems with BL
• Implementing tests may be not
as exciting as other activities^^
21. ┬──┬ ノ( ゜-゜ノ)
Property-based testing to the rescue!
Instead of defining actual VALUES in tests
and compare them we can verify
PROPERTIES of the rules
Arguments can be generated automatically
and be completely random
23. History
QuickCheck is a combinator
library originally written in Haskell,
designed to assist in software
testing by generating test cases for test
suites.
In QuickCheck the programmer writes
assertions about logical properties that
a function should fulfill. Then
QuickCheck attempts to generate a test
case that falsifies these assertions.
Once such a test case is found,
QuickCheck tries to reduce it to a
minimal failing subset by removing or
simplifying input data that are not
needed to make the test fail.
The project was started in 1999.
Currently there exist implementations
of QuickCheck for 30+ modernhttp://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdf
24. Property-based testing 101
Property-based testing (PBT) is a testing technique
that
tries to falsify a given property by generating
random input data and verifying the expected
behavior.
Properties can range from simple algebraic
equations to complex state machine models.
Like in all model-based testing techniques the
properties serve as a source for test-case
generation as well
25. Value-based vs. property-based testing
Assign inputs for case #1
Do the processing
Assert result
Assign inputs for case #2
Do the processing
Assert result
Assign inputs for case #3
Do the processing
Assert result
Describe the inputs
Describe the result
Profit!
26. FsCheck
.NET implementation of QuickCheck
written in F#
Works with specifications that are
expressed in F#, C# or VB.
FsCheck provides combinators to define
properties, observe the distribution of test
data, and define test data generators.
Used by:
FSharpx.Extras LinqOptimizer Neutronium
https://fscheck.github.io
27. FsCheck Generators
Generator – FsCheck.Gen<T> - tries to
create example inputs that tend
to grow larger. It begins by
generating small test cases, and
gradually increases the size as testing
progresses.
There are numerous built-in
generators for typical input types
(ints, floats, strings, lists, etc.) and
also possibility to generate custom
generators.
28. Built-in Generators
• Gen.Constant – always returns the same value
• Gen.Choose – generates singular integer values between a
minimum and maximum value
• Gen.Elements – generates singular values drawn from a
collection of possible values
• Gen.Map – gives ability to produce generator of one type
from another type
• Gen.ListOfLength – generate lists from individual value
generators
• Gen.Shuffle – a generator that generates a random
permutation of a given finite sequence.
• Gen.Two, Gen.Three, Gen.Four – generating tuples
• Gen.Filter – gives ability to apply custom rules for
generating values
30. FsCheck Shrinkers
When a property fails, FsCheck
automatically displays a minimal
counter example.
This is done with the help of
Shrinker T ->
IEnumerable<T> function that
works hand-in-hand with the
generator such that when a
failure is found, the input that
caused the failure is then
'shrunk' trying to find a smaller
input that also causes a failure.
31. FsCheck defines default test data generators and
shrinkers for some often used types, for example
unit, bool, byte, int, float, char, string, DateTime,
lists, array 1D and 2D, Set, Map, objects and
functions from and to any of the above.
Furthermore, by using reflection, FsCheck can derive
default implementations of record types,
discriminated unions, tuples, enums and basic classes
in terms of any primitive types that are defined (either
in FsCheck or by you).
FsCheck Shrinkers
33. Examples from OSS: Faker
faker-csharp/blob/master/tests/Faker.Models.Tests/ArrayHelperSpecs.cs
[TestFixture(Description = "Validates our extension methods for working with arrays")]
public class ArrayHelperSpecs
{
[Test(Description = "Ensure that our shuffle function works over a range of
intervals")]
public void Shuffled_lists_should_never_match_original()
{
Prop.ForAll<int[]>(original =>
{
var shuffle = original.Shuffle().ToArray();
return (!original.SequenceEqual(shuffle))
.When(original.Length > 1 && original.Distinct().Count() > 1)
.Label($"Expected shuffle({string.Join(",", shuffle)}) to be "
+ $"different than original({string.Join(",", original)})")
.And(original.All(x => shuffle.Contains(x))
.Label($"Expected shuffle({string.Join(",", shuffle)}) to contain"
+ $" same items as original({string.Join(",", original)})"));
}).QuickCheckThrowOnFailure();
}
}
36. Examples from OSS: LinqOptimizer
LinqOptimizer/tests/LinqOptimizer.Tests.CSharp/QueryTests.cs
[TestFixture]
public class QueryTests
{
[Test]
public void Select()
{
Func<IEnumerable<object>, bool> f = xs =>
{
var x = xs.AsQueryExpr().Select(n => n.ToString()).Run();
var y = xs.Select(n => n.ToString());
return Enumerable.SequenceEqual(x, y); };
Spec.ForAny<TestInput<object>>(xs =>
TestInput<object>.RunTestFunc<object>(f, xs))
.QuickCheckThrowOnFailure(); }
[Test]
public void Pipelined()
{
Spec.ForAny<int[]>(xs =>
{
var x = xs.AsQueryExpr().Where(n => n % 2 == 0)
.Select(n => n * 2).Select(n => n.ToString()).Select(n => n + "!").Run();
var y = xs .Where(n => n % 2 == 0)
.Select(n => n * 2) .Select(n => n.ToString()).Select(n => n + "!");
return Enumerable.SequenceEqual(x, y);
}).QuickCheckThrowOnFailure();
}
}
37. .ToArbitrary() – constructs an arbitrary instance
from generator
.Classify() – classifies test cases. Test cases
satisfying the condition are assigned the
classification given.
.Label () – adds the given label to the property.
The labels of a failing sub-property are displayed
when it fails.
.Sample (int size) – Generates n values of the
given size.
.VerboseCheckThrowOnFailure() – throws an
exception with the error message if the test fails or
is exhausted
Other points of interest
40. public class CapturingOutput
{
private readonly ITestOutputHelper _testOutputHelper;
public CapturingOutput(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}
[Fact]
public void CapturingOutput_Example()
{
Prop.ForAll(Arb.Default.Bool(), i => i)
.VerboseCheckThrowOnFailure(_testOutputHelper);
}
}
Capturing output
41. public class ReplayExample
{
[Fact]
public void Replay_Example()
{
Prop.ForAll(Arb.Default.Bool(), i => i)
.Check(new Configuration
{
Replay = Random.StdGen.NewStdGen(487723102, 296400248)
});
}
}
Replaying failed test
42. Quick summary
Not a silver bullet!
Property-based testing is yet another approach to
software testing
It may look as pure magic at first, but can help in
cases when conventional tests are hard to
implement or not efficient
Does not substitute value-based testing, but
complements it nicely
Gives another perspective and mindset during
coding and verification
43. Philosophical detour
There are two ways of constructing a software design:
One way is to make it so simple that there are obviously no
deficiencies, and the other way is to make it so complicated that
there are no obvious deficiencies.
The first method is far more difficult. It demands the same skill,
devotion, insight, and even inspiration as the discovery of the
simple physical laws which underlie the complex phenomena of
nature.
Charles Antony Richard Hoare (Tony Hoare)
1980 Turing Award Lecture
44. Properties patterns
“Different paths, same destination”
Combining operations in different
orders, but getting the same result
Examples:
Addition commutativity
Sorting lists
List reversal
45. Properties patterns
“There and back again”
Combining some operation with its
inverse should produce the source
input
Examples:
Any inverse operation
Addition/substraction
Write/read
Serialize/deserialize
Encipher/decipher
Set/get
Insert/contains
Create/exists
46. Properties patterns
“Some things never change”
Checking some invariant that is
preserved during transformation
Examples:
Size of collection
Contents of a collection
Measures proportion during scaling
47. Properties patterns
“The more things change, the more
they stay the same”
Idempotence property – doing the
same operation twice should be the
same as doing it once
Examples:
Database filtering
Database updates
Message processing
SOA?
48. Properties patterns
“Solve a smaller problem first”
Structural induction – if something
can be broken into smaller parts
and we prove some property is
true for all of them, we can prove
the property is true for the whole
structure
Examples:
Operations with recursive
structures such as lists and trees
49. Properties patterns
“Hard to prove, easy to verify”
Verifying results of some algorithm
is way easier than finding the
solution
Examples:
Shortest path in maze vs. valid path
Sort list/verify it is sorted
Prime number factorization
String tokenizer
50. Properties patterns
“The test oracle” aka “Two heads are
better than one”
Using alternate (simplified*) version
of an algorithm or process (a “test
oracle”) to check results
Examples:
Optimized high-performance
algorithm vs. brute force version
Parallel/concurrent algorithm vs.
linear/single-thread version
Data generators
51.
52. An introduction to property-based testing Or, why you should be using FsCheck and QuickCheck
https://fsharpforfunandprofit.com/posts/property-based-testing/
The lazy programmer's guide to writing 1000's of tests: An introduction to property based testing
https://skillsmatter.com/skillscasts/6432-the-lazy-programmers-guide-to-writing-1000s-of-
tests-an-introduction-to-property-based-testing
FsCheck
https://fscheck.github.io/FsCheck/index.html
QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs by Koen Claessen and John
Hughes
http://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdf
Software Fail Watch: 2016 in Review
https://www.tricentis.com/resource-assets/software-fail-watch-2016/
Property-based Testing with FsCheck by Deriving Properties from Business Rule Models. IEEE, 2016.
http://truconf.ist.tugraz.at/index.php/2016/03/04/publication-at-a-most-2016/
Agile Adoption: Improving Software Quality. Reducing Bugs and Improving Design
https://dzone.com/refcardz/agile-adoption-improving
John Hughes: Race Conditions, Distribution, Interactions — Testing the Hard Stuff and Staying Sane
https://vimeo.com/68383317
Discounts and allowances wiki article
https://en.wikipedia.org/wiki/Discounts_and_allowances#Dealing_with_quantity
Neutronium Github
https://github.com/NeutroniumCore/Neutronium
Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen
http://book.realworldhaskell.org/read/testing-and-quality-assurance.html
Exploring Test-Driven Development with QuickCheck
http://www.natpryce.com/articles/000795.html
Unit Test Boilerplate Generator
References: