kotlinjqwik

Constraining List values in jqwik with Kotlin


I'm writing jqwik tests in Kotlin. I have this parameter to one of my property tests:

@ForAll @Size(3) @UniqueElements emails: List<@Email @NotBlank String>

But when I run the test, it invariably produces

  emails: ["", "�", "A"]

which is clearly not following the constraint I thought I was giving. What am I doing wrong?


Solution

  • I just tried successfully:

    @Property(tries = 100)
    fun `stack overflow 77519262`(@ForAll @Size(3) @UniqueElements emails: List<@Email @NotBlank String>) {
        assert(emails.size == 3)
        assert(emails.toSet().size == 3)
        assert(emails.all { it.isNotBlank() })
        assert(emails.all { it.contains("@") })
    }
    

    I assume there's a misconfiguration on your side. Here's a few things that could go wrong: