Giter Club home page Giter Club logo

Comments (22)

brianm avatar brianm commented on July 20, 2024

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.

brianm avatar brianm commented on July 20, 2024

Confirmed, it happens on arrays but not single objects.

from jqwik.

jlink avatar jlink commented on July 20, 2024

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

  1. A code example or even a failing test
  2. The version numbers of all participating parties, in this case of jqwik, the junit platform and IntelliJ

from jqwik.

sormuras avatar sormuras commented on July 20, 2024

image

Looks like a bug in IDEA. The IDE should feed [B as the parameter type, @akozlova -- am I right?

from jqwik.

akozlova avatar akozlova commented on July 20, 2024

Please see junit-team/junit5#815. IDEA never passes VM names, only source names.

from jqwik.

sormuras avatar sormuras commented on July 20, 2024

I remember that one. Wasn't the solution to send byte[] instead of a mesh-up like [byte?

from jqwik.

akozlova avatar akozlova commented on July 20, 2024

I don't remember exactly, but [Ljava.lang.String; is similar to [byte to me.

from jqwik.

sormuras avatar sormuras commented on July 20, 2024

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:

https://junit.org/junit5/docs/current/api/org/junit/platform/commons/support/ReflectionSupport.html#loadClass-java.lang.String-

from jqwik.

sbrannen avatar sbrannen commented on July 20, 2024

This is a bug in IntelliJ.

The supported syntax is clearly documented here:

https://junit.org/junit5/docs/current/api/org/junit/platform/engine/discovery/DiscoverySelectors.html#selectMethod-java.lang.String-

from jqwik.

sbrannen avatar sbrannen commented on July 20, 2024

[byte is neither valid in source code nor in binary.

from jqwik.

sbrannen avatar sbrannen commented on July 20, 2024

@brianm,

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.

sbrannen avatar sbrannen commented on July 20, 2024

@akozlova,

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.

akozlova avatar akozlova commented on July 20, 2024

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.

sbrannen avatar sbrannen commented on July 20, 2024

@akozlova, no worries... We are all quite confident that you will fix it blazingly fast (as always)! 😉

from jqwik.

brianm avatar brianm commented on July 20, 2024

Wow, ya'll rock. Thank you! Apologies for no test code :-(

from jqwik.

jlink avatar jlink commented on July 20, 2024

@akozlova Any news on this front?

from jqwik.

akozlova avatar akozlova commented on July 20, 2024

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.

jlink avatar jlink commented on July 20, 2024

Has been fixed in in IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-189846

Available probably in version 2018.2

from jqwik.

jlink avatar jlink commented on July 20, 2024

@akozlova Thanks, the fix somehow slipped my mind.

from jqwik.

jlink avatar jlink commented on July 20, 2024

The fix is included in IntelliJ 2018.2. Everything works as expected :-)

from jqwik.

nick318 avatar nick318 commented on July 20, 2024

@jlink seems the issue reproduces again using jqwik 1.3.0 and IDEA 2020.1.
Version 1.2.0 works fine

from jqwik.

jlink avatar jlink commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.