BadMrStinger

BadMrStinger

Negative Property Test Cases

I am having a hard time coming up with negative tests. I believe it can be done with filters, but I haven’t been able to come up good working case.

Say I have this test case:

property “Positive Test” do
check all variable1 ← StreamData.integer(1..5) do
assert Enum.member?([1,2,3,4,5], variable1) == true
end
end

I would like to perform a negative test

property “Negative Test” do
check all variable1 ← !(StreamData.integer(1..5)) do
assert Enum.member?([1,2,3,4,5], variable1) == false
end
end

where !(StreamData.integer(1..5)) is any input that is the “opposite” of the valid input.

I generated a bad negative test that simply generates any term and that test has always passed, but I understand it is not mutually exclusive.

Two thoughts it would be nice if we had two types of “opposite”:

  • One that is bound to the same variable type
  • The other or any term.

In this way I could show that if a valid input exists it works, if an invalid input of the same data type is provided it fails, and all other results crash.

This would allow for the ability to potentially have a test cases that could catch any case that was expected to crash and didn’t (hardware failure?).

I would really like to take all of the properties from the positive property test and negate it, but I don’t know if this would really work for more complex properties.

All suggestion would be greatly appriciated!

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

Other popular topics Top

New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

We're in Beta

About us Mission Statement