{"id":20550886,"url":"https://github.com/artodeschini/usejunit5","last_synced_at":"2026-04-15T20:32:43.999Z","repository":{"id":113860574,"uuid":"136518144","full_name":"artodeschini/UseJunit5","owner":"artodeschini","description":"Test With JUnit 5","archived":false,"fork":false,"pushed_at":"2018-06-07T21:04:07.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T05:45:33.353Z","etag":null,"topics":["java8","junit-5-tutorial","junit5","maven","unit-testing"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artodeschini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-07T18:47:55.000Z","updated_at":"2018-06-07T21:04:08.000Z","dependencies_parsed_at":"2023-07-13T21:01:05.425Z","dependency_job_id":null,"html_url":"https://github.com/artodeschini/UseJunit5","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/artodeschini/UseJunit5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artodeschini%2FUseJunit5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artodeschini%2FUseJunit5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artodeschini%2FUseJunit5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artodeschini%2FUseJunit5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artodeschini","download_url":"https://codeload.github.com/artodeschini/UseJunit5/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artodeschini%2FUseJunit5/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31859394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java8","junit-5-tutorial","junit5","maven","unit-testing"],"created_at":"2024-11-16T02:27:46.962Z","updated_at":"2026-04-15T20:32:43.981Z","avatar_url":"https://github.com/artodeschini.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"README.md\n# UseJunit5\nTest With JUnit 5\n\nTo create a simple test\n\nCreate a class\nin the class\n\ncreate a void method\nuse the @Test\n\nuse the basics \n\nassertEquals\nexpected / actual\n\ncheck is a object is not null\nassertNotNull \n\ncheck is a object is null\nassertNull\n\nfor boolean values\ncheck is actual is false\nassertFalse\n\ncheck is actual is true\nassertTrue\n\nto Array\ncheck is one array is same than another\nassertArrayEquals( expected , actual );\nthis check all position same equals and the size is the same\n\nthe annotation @BeforeEach\nis execute before (antes) all test\nif you has 3 test the method is run 3 times\n\nthe annotation @AfterEach\nis execute after (depois) all test\nif you has 3 test the method is run 3 times\n\nthe methods with @BeforeEach and @AfterEach\nyou can use a parameter TestInfo\nwith a instance o TestInfo you can get the name of method\n\nWith the JUnit 4 use @Before and @After but the TestInfo not present\nTestInfo is only in JUnit 5\n\nYou can use the @BeforeAll to connect the database for exemple\nthis method need to be static\nthe method is call frist before than all tests\n\nYou can use the @AfterAll to close connect the database for exemple\nthis method need to be static\nthe method is call after before than all tests\n\nIn JUnit 5 the word public is not required in test's\n\nthe annotation @DisplayName show the message that you put in before run the test\n\n@ParameterizedTest\nyou can use multiple values with this annotation\nuse with the @ValueSource\nsample\n@ParameterizedTest\n@ValueSource(strings= { \"ABCD\" , \"ABC\", \"AB\" } )\nvoid lengthMoreThanZeroParametrize(String string) {\n    assertTrue( string.length() \u003e 0 );\n}\n\n//Sample to give name to ParameterizedTest\nI can change the output of test with\n@ParameterizedTest( name = \"the string {0} length is {1}\") //change de out put {0} before ',' and {1} after ',\n\nI can repeat many time with RepeatedTest\n@RepeatedTest( 3 )\n\nI can try de performace with assertTimeout\nUse a the aegs : \naTime, () -\u003e { \u003cmy source\u003e }   \nassertTimeout( Duration.ofSeconds(5), () -\u003e {\n            for (int i = 0; i \u003c 100; i++ ) {\n                System.out.println( i );\n            }\n        });\n\n\nI can disable a test @Disabled in JUnit 5 with 4 use @Ignored\n\nIf I can not run any Test in a class I use @Disable in the class \nwhen I use in classe any test not run\n\nthe annotation @Nested \nI can use to use a nested class when a run a test\n\nJUnit 5 x JUnit 4 != \n@BeforeAll instead of @BeforeClass\n@AfterAll instead of @AfterClass\n@BeforeEach instead of @Before\n@AfterEach instead of @After\n@Disable instead of @Ignote\n@Tag instead of @Category\nassertThrows instead of expected attibute\nassertTimeout instead of timeout attibute\n\nNew in JUnit 5\n@Nested for nested tests\n@RepeatedTest to execute tests mulpiple times\n\nBest pratices for good unit test\n1 Readable\nLook at the test and you know what is begin tested\n(I can read the class test and know what the test is do in 15 seconds)\n\n2 Fast\nwhat happerns if unit tests take a long time to run?\n(think abaout what the advantage of unit test is lost 2 hours?)\n\n3 Isolated\nFails only when there is an issue whith code!\n(is not good if they star failing because of an external depedency not avaliable then the fail)\n\n4 Run often\nWhat is the use having unit test which are note run frenquently?\nWhat happens if you do not commit code often?\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartodeschini%2Fusejunit5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartodeschini%2Fusejunit5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartodeschini%2Fusejunit5/lists"}