Skip to content

Singleton generator#218

Merged
KristianKarl merged 11 commits intoGraphWalker:masterfrom
KristianKarl:singletonGenerator
Nov 26, 2019
Merged

Singleton generator#218
KristianKarl merged 11 commits intoGraphWalker:masterfrom
KristianKarl:singletonGenerator

Conversation

@KristianKarl
Copy link
Copy Markdown
Contributor

@KristianKarl KristianKarl commented Nov 26, 2019

Lets a user to reproduce the same path over and over again.

When graphwalker uses the random generator, the seed is logged (on INFO level). For example:

java -jar graphwalker-cli/target/graphwalker-cli-4.1.0-SNAPSHOT.jar -d INFO offline -g graphwalker-io/src/test/resources/json/petClinic.json|head
{"currentElementName":"e_StartBrowser"}
09:47:43.252 [main] INFO org.graphwalker.core.generator.SingletonRandomGenerator - Seed: 67300799054828
{"currentElementName":"v_HomePage"}
{"currentElementName":"e_Veterinarians"}
{"currentElementName":"v_Veterinarians"}
{"currentElementName":"v_Veterinarians"}
:

That seed can be reused when put in the json file, add for instance "seed": 67300799054828, to the file.
See petClinicWithSeed.json for an example.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Nov 26, 2019

Codecov Report

Merging #218 into master will decrease coverage by 0.1%.
The diff coverage is 68%.

@@             Coverage Diff              @@
##             master     #218      +/-   ##
============================================
- Coverage     76.17%   76.07%   -0.11%     
- Complexity     1176     1187      +11     
============================================
  Files           126      127       +1     
  Lines          4332     4368      +36     
  Branches        655      656       +1     
============================================
+ Hits           3300     3323      +23     
- Misses          802      814      +12     
- Partials        230      231       +1

@KristianKarl
Copy link
Copy Markdown
Contributor Author

One problem with this PR is the introduction of a singleton, which complicates things when running unit tests. See https://dzone.com/articles/singleton-anti-pattern
But in this case, it adds a very useful feature. So in this case I'd say it's worth the complications.

@KristianKarl
Copy link
Copy Markdown
Contributor Author

@nilols a review pretty plz?

@KristianKarl KristianKarl merged commit 9c08866 into GraphWalker:master Nov 26, 2019
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.

3 participants