Comments (22)
Debugging into this, it looks like the discovery request for (byte[], byte[]) param types comes in as [byte,[byte
which explodicates. I cannot find docs for the protocol for passing in method param type descriptors, and the javadocs on MethodSelector are... not awesome.
from jqwik.
Confirmed, it happens on arrays but not single objects.
from jqwik.
Checked it. Here's what I found...
Overview
The problem seems to occur only with primitive array types. And it does not occure withing the jqwik part of the execution chain. Which sounds like a good thing for me - because I don't have to fix it - but it's also a bad thing for me - because I CANNOT fix it :-(
Details
The selector (an instance of class MethodSelector
) that jqwik gets from the framework (aka JUnit Platform) is wrong. Wrong in the sense
that there's a method parameter type encoded as "[byte" which should be encoded as "[B". So the problem lies either in IntelliJ code or in some JUnit 5 platform support code. I'd bet on the former if I had to.
What you can do
If you care enough for the problem to be fixed, you should do the following:
- Reproduce the bug with a parameterized Jupiter test. Why? Because Jupiter (aka JUnit 5) is much more common than jqwik and will attract more attention.
- Open an issue for both junit5 and IntelliJ
- Add the links to the issues here, so that I can also track any advances in this topic.
- Hope that the JUnit team and the IntelliJ team will sort out the underlying problem.
I'm sorry that I can't offer a better solution.
One more thing
It's helpful for any issue you create to provide at least
- A code example or even a failing test
- The version numbers of all participating parties, in this case of jqwik, the junit platform and IntelliJ
from jqwik.
Looks like a bug in IDEA. The IDE should feed [B
as the parameter type, @akozlova -- am I right?
from jqwik.
Please see junit-team/junit5#815. IDEA never passes VM names, only source names.
from jqwik.
I remember that one. Wasn't the solution to send byte[]
instead of a mesh-up like [byte
?
from jqwik.
I don't remember exactly, but [Ljava.lang.String;
is similar to [byte
to me.
from jqwik.
We should take the discussion over to junit-team/junit5#815
@brianm a possible work-around is to use java.nio.ByteBuffer
for now. Replace byte[] data
with ByteBuffer data
in your test method and wrap the bytes with ByteBuffer.wrap(...)
.
Edit
I cannot find docs for the protocol for passing in method param type descriptors, and the javadocs on MethodSelector are... not awesome.
ReflectionSupport.loadClass
doc contains the information you were looking for:
from jqwik.
This is a bug in IntelliJ.
The supported syntax is clearly documented here:
from jqwik.
[byte
is neither valid in source code nor in binary.
from jqwik.
I cannot find docs for the protocol for passing in method param type descriptors, and the javadocs on MethodSelector are... not awesome.
Good point.
I introduced cross referencing in this commit.
from jqwik.
I don't remember exactly, but
[Ljava.lang.String;
is similar to[byte
to me.
Yep, it is indeed similar but unfortunately unsupported.
Will you raise an issue against IDEA for this?
from jqwik.
This will teach me again to do nothing before I actually can check it. I had a test data for [int array which I thought would be supported. Here is the IDEA issue: https://youtrack.jetbrains.com/issue/IDEA-189846
from jqwik.
@akozlova, no worries... We are all quite confident that you will fix it blazingly fast (as always)! 😉
from jqwik.
Wow, ya'll rock. Thank you! Apologies for no test code :-(
from jqwik.
@akozlova Any news on this front?
from jqwik.
I've created issue in IDEA's tracker (IDEA-189846) and resolved it in the same day. I am not aware of anything else I should do here.
from jqwik.
Has been fixed in in IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-189846
Available probably in version 2018.2
from jqwik.
@akozlova Thanks, the fix somehow slipped my mind.
from jqwik.
The fix is included in IntelliJ 2018.2. Everything works as expected :-)
from jqwik.
@jlink seems the issue reproduces again using jqwik 1.3.0 and IDEA 2020.1.
Version 1.2.0 works fine
from jqwik.
I cannot reproduce with
@Property
void test(@ForAll byte[] bytes) {}
@nick318 Can you be more specific about the failure you are observing?
from jqwik.
Related Issues (20)
- Consider supporting @UseType for sealed interfaces HOT 8
- Shrinking of large arrays uses a very large amount of memory HOT 11
- StackOverflowError when shrinking large arrays HOT 14
- question: any way to imperatively summon a pre-configured arbitrary? HOT 15
- Make nested groups work for JDK >= 18 HOT 31
- Combinators.combine.as nullability of arguments HOT 4
- Can't figure out how to create an Arbitrary I want HOT 10
- Bug: Arbitraries.strings().uniqueChars() will sometimes shrink to values with duplicate chars HOT 5
- Bug: Uniform Distribution of Integers does not work if range is >= Integer.MAX_VALUE HOT 2
- Kotlin K2 Support HOT 23
- Time Module: Support generating java.sql.Timestamp
- adding `jqwik-kotlin` causes existing tests written in java to fail with NPE HOT 18
- Potential idea for running `SAMPLE_FIRST`/`SAMPLE_ONLY` for stateful tests HOT 2
- Lifecycle method called twice when subclassing HOT 4
- Cannot use Arbitrary.generator() outside jqwik HOT 6
- Is Arbitrary<@Nullable T> correct/intended under JSpecify semantics? HOT 32
- TypeUsage example from user guide fails in 1.8.x HOT 8
- Right Way to Integrate jqwik with DataFaker HOT 23
- Generic @Provide methods are sensitive to the type variables' names HOT 3
- Allowing Sampling of Arbitraries with Injected Seed HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jqwik.