Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide unique IDs for all node info objects #1696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Vampire
Copy link
Member

@Vampire Vampire commented Jun 10, 2023

No description provided.

@Vampire
Copy link
Member Author

Vampire commented Jun 10, 2023

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Vampire and the rest of your teammates on Graphite Graphite

@codecov
Copy link

codecov bot commented Jun 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.18%. Comparing base (2c7db77) to head (f918dea).
Report is 96 commits behind head on master.

Current head f918dea differs from pull request most recent head 9bffe3b

Please upload reports for the commit 9bffe3b to get more accurate results.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1696      +/-   ##
============================================
- Coverage     80.44%   80.18%   -0.27%     
+ Complexity     4337     4299      -38     
============================================
  Files           441      439       -2     
  Lines         13534    13481      -53     
  Branches       1707     1701       -6     
============================================
- Hits          10888    10810      -78     
- Misses         2008     2026      +18     
- Partials        638      645       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leonard84
Copy link
Member

What is the use-case? And shouldn't we have something that is stable across invocations, otherwise it's use is severely limited.

@Vampire
Copy link
Member Author

Vampire commented Aug 21, 2023

What is the use-case?

Well, everytime you need a unique ID during the test.
One use-case where I needed it is for example to put it as thread context map entry to log messages, so that you can identify log messages belonging to an iteration and test logging behavior in a multi-threaded SUT.

And shouldn't we have something that is stable across invocations, otherwise it's use is severely limited.

Well, the intended use by me was during one test run to relate things, without needing to build a unique ID yourself.
And for spec info, feature info and iteration info, it actually is stable across invocations, just not for "other" nodes.
Others being data provider info, field info, method info and parameter info.

Not sure whether we need stable unique ids for those. :-/

@Vampire
Copy link
Member Author

Vampire commented Aug 22, 2023

Also, that they are stable across invocations for spec, feature, and iteration info is mainly a side-effect. The goal was to have something descriptive that can the also easily be readable for example in the log output where I intend to use it. :-D

@Vampire Vampire force-pushed the unique-node-ids branch 2 times, most recently from 82329d4 to 9e20670 Compare September 16, 2023 10:37
@Vampire Vampire force-pushed the unique-node-ids branch 2 times, most recently from 0a54c3f to 53f0557 Compare September 18, 2023 23:41
@Vampire Vampire force-pushed the unique-node-ids branch 3 times, most recently from 5c9ac8c to 02aff00 Compare October 14, 2023 11:36
@Vampire Vampire force-pushed the unique-node-ids branch 3 times, most recently from 6e21a45 to b3d7dbb Compare November 7, 2023 00:29
@Vampire Vampire force-pushed the unique-node-ids branch 4 times, most recently from 2caee62 to 6c400f0 Compare November 13, 2023 00:50
@Vampire Vampire force-pushed the unique-node-ids branch 4 times, most recently from 0422e2b to d6e3be7 Compare November 30, 2023 13:08
@leonard84
Copy link
Member

With the current code you could easily externalize it to a helper function. I don't see a strong reason to add it to the API and only see potential problems when we'll add #1153.

@Vampire
Copy link
Member Author

Vampire commented Dec 1, 2023

I don't see where there should be problems with #1153.
You probably have a "spec iteration index" for data-driven specs and can attach that to the spec unique id like for feature iterations.
Or there will maybe be a SpecIterationInfo for data driven specs.
However it will look, I'd expect it to be trivial to maintain unique ids still.

Of course the code can also be written in any project that needs such an ID.
I currently use

public static String getIterationIdentifier(IterationInfo iterationInfo) {
    FeatureInfo featureInfo = iterationInfo.getParent();
    SpecInfo specInfo = featureInfo.getParent();

    return new StringJoiner(".")
            .add(specInfo.getReflection().getName())
            .add(featureInfo.getFeatureMethod().getReflection().getName())
            .add(String.valueOf(iterationInfo.getIterationIndex()))
            .toString();
}

But I thought it would be nice to provide ready-made values already for such use-cases.

@Vampire Vampire force-pushed the unique-node-ids branch 2 times, most recently from 077181e to f918dea Compare December 18, 2023 12:50
@Vampire Vampire force-pushed the unique-node-ids branch 2 times, most recently from 5c0aee8 to 5d2e2d8 Compare March 10, 2024 16:20
@Vampire Vampire force-pushed the unique-node-ids branch 7 times, most recently from 8814399 to 3db8d21 Compare March 20, 2024 16:48
@leonard84
Copy link
Member

Given that we now have the extension store, do you still see a need?
IMHO, it is too niche to be added to spock-core.

@Vampire
Copy link
Member Author

Vampire commented Mar 20, 2024

I don't know how this is in any way related to the extension store.
The extension store provides a place to put things at.
This provides a unique ID identifying a spec / a feature / an interation / ...
They don't really have anything in common, unless you use the ID as a key for a map, but then you could also just use the node itself as key.

So yes, I still see the need and imho it is not really niche or I wouldn't have created a PR.
But if you don't agree, we can of course also close this, not a problem for me, everyone that needs it can generate such an id theirselves.

@Vampire Vampire force-pushed the unique-node-ids branch 5 times, most recently from a174c62 to 56d0cdf Compare March 23, 2024 23:32
@Vampire Vampire force-pushed the unique-node-ids branch 2 times, most recently from 06305f1 to ab7b2cd Compare April 22, 2024 20:34
@Vampire Vampire force-pushed the unique-node-ids branch 3 times, most recently from 937bf52 to 60bf169 Compare May 16, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants