Editing
PropEr
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==PropEr== [[File:PropEr_logo.png|thumb|right|PropEr logo]] PropEr is a property-based testing tool for the Elixir programming language. It allows developers to express and verify properties of their code through automated testing. By generating random input data and testing code against specified conditions, PropEr helps identify bugs, edge cases, and corner scenarios that may not be immediately apparent. ===Features=== PropEr offers several powerful features that make it a valuable tool for Elixir developers: * **QuickCheck-style Properties**: PropEr enables developers to define properties with assertions about the expected behavior of their code. * **Automated Test Generation**: PropEr generates random test data based on the properties defined, providing comprehensive test coverage. * **Shrinking Mechanism**: When a property fails, PropEr automatically minimizes the generated counterexample, making it easier to debug and fix the issue. * **Integration with Elixir**: PropEr seamlessly integrates with the Elixir ecosystem, leveraging Elixir's robust features and libraries. * **Custom Generators**: PropEr allows developers to define custom data generators, enabling them to test code with specific input requirements. * **Stateful Testing**: PropEr supports stateful testing, allowing developers to define and test code that maintains internal state. ===Getting Started=== To use PropEr in an Elixir project, follow these steps: 1. Install PropEr by adding it as a dependency in your `mix.exs` file: ```elixir defp deps do [ {:proper, "~> x.x.x"} ] end ``` 2. Run the `mix deps.get` command to fetch and compile the dependency. 3. Define properties in your test modules using the `@proper` attribute: ```elixir defmodule MyModuleTest do use ExUnit.Case use PropEr.Property # Define properties using the @proper attribute @proper my_property do forall {x, y} <- proper_gen.int(), do: x + y == y + x end # Run the properties using proper_check/2 test "property test" do PropEr.check_all() end end ``` 4. Run the tests using the `mix test` command, which will execute both regular tests and property-based tests. ===Resources=== To further explore PropEr and property-based testing in Elixir, check out the following resources: * [https://hexdocs.pm/proper/readme.html PropEr Documentation]: The official documentation provides comprehensive information on installing, configuring, and using PropEr. * [https://github.com/proper-testing/proper PropEr GitHub Repository]: The source code repository for PropEr contains the latest code, issues, and contributions. * [https://elixir-lang.org/getting-started/elixir-and-mix.html Elixir and Mix Guide]: If you are new to Elixir, this guide will help you learn the basics of Elixir and how to use Mix, Elixir's build tool. ==See Also== * [[Elixir]]: An introduction to the Elixir programming language. * [[ExUnit]]: Elixir's built-in test framework used for testing Elixir code. * [[QuickCheck]]: An influential property-based testing tool for functional programming languages. [[Category:Elixir]] [[Category:Testing]] [[Category:Elixir Testing Tools]]
Summary:
Please note that all contributions to Elixir Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Elixir Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information