Giter Site home page Giter Site logo

bonigarcia / mastering-junit5 Goto Github PK

View Code? Open in Web Editor NEW
404.0 19.0 232.0 3.21 MB

Examples of the Packt book "Mastering Software Testing with JUnit 5"

License: Apache License 2.0

Java 99.20% HTML 0.10% Gherkin 0.70%
junit5 java mockito spring-boot docker selenium appium android rest junit

mastering-junit5's Introduction

mastering-junit5's People

Contributors

bonigarcia avatar corneilleedi avatar dependabot-preview[bot] avatar dependabot[bot] avatar lorenzobettini avatar sskorol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mastering-junit5's Issues

junit-jupiter-engine should be in dependencies to run it from Eclipse

If you put junit-jupiter-engine as a dependency in surefire configuration only, then the tests can't be run in Eclipse with an exception (see below).

Note that junit-jupiter-engine is in the main dependencies section also in the official JUnit Maven example, https://github.com/junit-team/junit5-samples/blob/r5.0.3/junit5-vanilla-maven/pom.xml

I'l submit a PR shortly (only for the hello project)

java.lang.NoClassDefFoundError:
org/junit/platform/engine/EngineDiscoveryRequest
	at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:59)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:31)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:367)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:362)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:306)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:221)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:205)
Caused by: java.lang.ClassNotFoundException:
org.junit.platform.engine.EngineDiscoveryRequest
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 12 more

Paralellel execution doesn't work properly

Module: junit5-cucumber-selenium
Chrome: 117
macOs Ventura 13.4

Step to reproduce:

  1. Update junit-platform.properties
    cucumber.publish.quiet=true cucumber.execution.parallel.enabled=true cucumber.execution.parallel.config.strategy=fixed cucumber.execution.parallel.config.fixed.parallelism=2

  2. Duplicate test scenarios(login.feature) to increase the total number of tests. For example create 10 tests.

  3. Run the 'CucumberTest' java class

Expected:
Tests should be executed in parallel in 2 thread

Actual:
All tests started simultaneously in 10 Threads(thread number=total number of tests)

junit5-cucumber is broken

I did see issue #3, but the fact remains that as is, the junit5-cucumber example is still broken and fails. Removing the CucumberExtension dependency did not fix nor made the problem go away.

โžœ junit5-cucumber git:(master) mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building junit5-cucumber 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ junit5-cucumber ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ junit5-cucumber ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ junit5-cucumber ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jsalido/code/mastering-junit5/junit5-cucumber/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ junit5-cucumber ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ junit5-cucumber ---


T E S T S

Running io.github.bonigarcia.CucumberTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.058 sec <<< FAILURE! - in io.github.bonigarcia.CucumberTest
runTests(Stream) Time elapsed: 0.055 sec <<< FAILURE!
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.util.stream.Stream<org.junit.jupiter.api.DynamicTest> arg0] in executable [public java.util.stream.Stream<org.junit.jupiter.api.DynamicTest> io.github.bonigarcia.CucumberTest.runTests(java.util.stream.Stream<org.junit.jupiter.api.DynamicTest>)].

Results :

Failed tests:
CucumberTest.runTests ยป ParameterResolution No ParameterResolver registered fo...

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.433 s
[INFO] Finished at: 2018-02-08T21:51:21Z
[INFO] Final Memory: 31M/2944M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project junit5-cucumber: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/jsalido/code/mastering-junit5/junit5-cucumber/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Cucumber generating empty reports

Hi,
If I add some properties:
cucumber.publish.enabled=false
cucumber.plugin=pretty, summary, html:target/cucumber-reports/cucumber.html, json:target/cucumber-reports/cucumber.json, junit:target/cucumber-reports/cucumber.xml

to junit-platform.properties in module junit5-cucumber then the directory cucumber-reports in target is created.
It has 3 files, but each one is empty.

Do you know how to fix it?

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.