Update the link for Junit 4 and @Before

This commit is contained in:
YuCheng Hu 2021-11-22 14:40:32 -05:00
parent 6e4a769626
commit 7add8d736b
8 changed files with 155 additions and 62 deletions

View File

@ -6,12 +6,46 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="codebank" />
<module name="math-test-functions" />
<module name="java-numbers-2" />
<module name="java-numbers" />
<module name="jmh" />
<module name="assertion-libraries" />
<module name="cucumber" />
<module name="java-numbers" />
<module name="mockito" />
<module name="test-containers" />
<module name="spring-testing-2" />
<module name="mockserver" />
<module name="spring-testing" />
<module name="xml" />
<module name="testing-libraries" />
<module name="mocks" />
<module name="load-testing-comparison" />
<module name="junit-5-basics" />
<module name="mockito-2" />
<module name="groovy-spock" />
<module name="codebank" />
<module name="easymock" />
<module name="testing-assertions" />
<module name="selenium-junit-testng" />
<module name="junit5-annotations" />
<module name="mockito-3" />
<module name="powermock" />
<module name="junit5-migration" />
<module name="easy-random" />
<module name="gatling" />
<module name="junit-5" />
<module name="zerocode" />
<module name="junit-4" />
<module name="discourse" />
<module name="junit-5-advanced" />
<module name="rest-assured" />
<module name="rest-testing" />
<module name="testing-libraries-2" />
<module name="string-test-functions" />
<module name="xmlunit-2" />
<module name="hamcrest" />
<module name="testng" />
</profile>
</annotationProcessing>
</component>

View File

@ -8,6 +8,9 @@
<file url="file://$PROJECT_DIR$/parent-java/jmh/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/testing/junit-5-basics/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/testing/junit-5-basics/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/testing/junit-5-basics/src/test/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/toolkits/codebank/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/toolkits/discourse/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/xml/src/main/java" charset="UTF-8" />

6
.idea/jpa-buddy.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="defaultUnitInitialized" value="true" />
</component>
</project>

View File

@ -4,9 +4,15 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="2a855b03-5ee0-4324-b916-110994784a14" name="Changes" comment="Update link for Java Microbenchmark Harness">
<list default="true" id="2a855b03-5ee0-4324-b916-110994784a14" name="Changes" comment="Rename package to ossez">
<change afterPath="$PROJECT_DIR$/.idea/jpa-buddy.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/persistence-modules/hibernate-annotations/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/persistence-modules/hibernate-annotations/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/testing/junit-5-basics/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/testing/junit-5-basics/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/testing/junit-5-basics/src/test/java/com/ossez/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/testing/junit-5-basics/src/test/java/com/ossez/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -24,6 +30,18 @@
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="JpbToolWindowState">
<option name="myId2FirstActivated">
<map>
<entry key="JPA Structure" value="true" />
</map>
</option>
<option name="myId2Visible">
<map>
<entry key="JPA Structure" value="false" />
</map>
</option>
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
@ -39,6 +57,7 @@
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="TF_FMT" value="false" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests" />
@ -60,20 +79,7 @@
<recent name="D:\WorkDir\Repository\GitHub\cwiki-us-docs\java-tutorials" />
</key>
</component>
<component name="RunManager" selected="Application.Main">
<configuration name="BenchmarkRunner" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.ossez.BenchmarkRunner" />
<module name="jmh" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ossez.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<component name="RunManager" selected="JUnit.BeforeAllAndAfterAllAnnotationsUnitTest">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.ossez.codebank.algorithm.Main" />
<module name="parent-modules" />
@ -87,49 +93,63 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="BlankTemplateTest.testBlank" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="parent-modules" />
<configuration name="BeforeAllAndAfterAllAnnotationsUnitTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="junit-5-basics" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ossez.codebank.algorithm.tests.*" />
<option name="PATTERN" value="com.ossez.migration.junit5.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.ossez.codebank.algorithm.tests" />
<option name="MAIN_CLASS_NAME" value="com.ossez.codebank.algorithm.tests.BlankTemplateTest" />
<option name="METHOD_NAME" value="testBlank" />
<option name="PACKAGE_NAME" value="com.ossez.migration.junit5" />
<option name="MAIN_CLASS_NAME" value="com.ossez.migration.junit5.BeforeAllAndAfterAllAnnotationsUnitTest" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="BeforeEachAndAfterEachAnnotationsUnitTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="junit-5-basics" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.baeldung.migration.junit5.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.baeldung.migration.junit5" />
<option name="MAIN_CLASS_NAME" value="com.baeldung.migration.junit5.BeforeEachAndAfterEachAnnotationsUnitTest" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="BeforeEachAndAfterEachAnnotationsUnitTest.whenCheckingListSizeAgain_ThenSizeEqualsToInit" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="junit-5-basics" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.baeldung.migration.junit5.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.baeldung.migration.junit5" />
<option name="MAIN_CLASS_NAME" value="com.baeldung.migration.junit5.BeforeEachAndAfterEachAnnotationsUnitTest" />
<option name="METHOD_NAME" value="whenCheckingListSizeAgain_ThenSizeEqualsToInit" />
<option name="TEST_OBJECT" value="method" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Dom4JParserUnitTest.testCreateXML" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="xml" />
<configuration name="BeforeEachAndAfterEachAnnotationsUnitTest.whenCheckingListSize_ThenSizeEqualsToInit" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="junit-5-basics" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ossez.xml.*" />
<option name="PATTERN" value="com.baeldung.migration.junit5.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.ossez.xml" />
<option name="MAIN_CLASS_NAME" value="com.ossez.xml.Dom4JParserUnitTest" />
<option name="METHOD_NAME" value="testCreateXML" />
<option name="TEST_OBJECT" value="method" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Dom4JParserUnitTest.testCreateXMLFromSystemProperties" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="xml" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ossez.xml.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.ossez.xml" />
<option name="MAIN_CLASS_NAME" value="com.ossez.xml.Dom4JParserUnitTest" />
<option name="METHOD_NAME" value="testCreateXMLFromSystemProperties" />
<option name="PACKAGE_NAME" value="com.baeldung.migration.junit5" />
<option name="MAIN_CLASS_NAME" value="com.baeldung.migration.junit5.BeforeEachAndAfterEachAnnotationsUnitTest" />
<option name="METHOD_NAME" value="whenCheckingListSize_ThenSizeEqualsToInit" />
<option name="TEST_OBJECT" value="method" />
<method v="2">
<option name="Make" enabled="true" />
@ -147,19 +167,19 @@
</method>
</configuration>
<list>
<item itemvalue="Application.BenchmarkRunner" />
<item itemvalue="JUnit.Dom4JParserUnitTest.testCreateXML" />
<item itemvalue="JUnit.Dom4JParserUnitTest.testCreateXMLFromSystemProperties" />
<item itemvalue="JUnit.BlankTemplateTest.testBlank" />
<item itemvalue="Application.Main" />
<item itemvalue="JUnit.BeforeEachAndAfterEachAnnotationsUnitTest.whenCheckingListSizeAgain_ThenSizeEqualsToInit" />
<item itemvalue="JUnit.BeforeEachAndAfterEachAnnotationsUnitTest.whenCheckingListSize_ThenSizeEqualsToInit" />
<item itemvalue="JUnit.BeforeEachAndAfterEachAnnotationsUnitTest" />
<item itemvalue="JUnit.BeforeAllAndAfterAllAnnotationsUnitTest" />
</list>
<recent_temporary>
<list>
<item itemvalue="JUnit.BeforeAllAndAfterAllAnnotationsUnitTest" />
<item itemvalue="JUnit.BeforeEachAndAfterEachAnnotationsUnitTest" />
<item itemvalue="JUnit.BeforeEachAndAfterEachAnnotationsUnitTest.whenCheckingListSize_ThenSizeEqualsToInit" />
<item itemvalue="JUnit.BeforeEachAndAfterEachAnnotationsUnitTest.whenCheckingListSizeAgain_ThenSizeEqualsToInit" />
<item itemvalue="Application.Main" />
<item itemvalue="JUnit.BlankTemplateTest.testBlank" />
<item itemvalue="Application.BenchmarkRunner" />
<item itemvalue="JUnit.Dom4JParserUnitTest.testCreateXMLFromSystemProperties" />
<item itemvalue="JUnit.Dom4JParserUnitTest.testCreateXML" />
</list>
</recent_temporary>
</component>
@ -182,7 +202,8 @@
<workItem from="1633632654458" duration="752000" />
<workItem from="1635345165318" duration="10334000" />
<workItem from="1635444765485" duration="1914000" />
<workItem from="1636036083756" duration="1603000" />
<workItem from="1636036083756" duration="1939000" />
<workItem from="1637604679020" duration="3881000" />
</task>
<task id="LOCAL-00001" summary="修改项目到不同的路径">
<created>1632420206392</created>
@ -268,7 +289,28 @@
<option name="project" value="LOCAL" />
<updated>1633632799545</updated>
</task>
<option name="localTasksCounter" value="13" />
<task id="LOCAL-00013" summary="Main test function">
<created>1636038085011</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1636038085011</updated>
</task>
<task id="LOCAL-00014" summary="Add Junit5 test base">
<created>1637605886622</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1637605886622</updated>
</task>
<task id="LOCAL-00015" summary="Rename package to ossez">
<created>1637606120688</created>
<option name="number" value="00015" />
<option name="presentableId" value="LOCAL-00015" />
<option name="project" value="LOCAL" />
<updated>1637606120688</updated>
</task>
<option name="localTasksCounter" value="16" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -297,7 +339,10 @@
<MESSAGE value="Add JMH document and source code" />
<MESSAGE value="Add compiler for JMH https://www.ossez.com/t/intellij-idea/13759" />
<MESSAGE value="Update link for Java Microbenchmark Harness" />
<option name="LAST_COMMIT_MESSAGE" value="Update link for Java Microbenchmark Harness" />
<MESSAGE value="Main test function" />
<MESSAGE value="Add Junit5 test base" />
<MESSAGE value="Rename package to ossez" />
<option name="LAST_COMMIT_MESSAGE" value="Rename package to ossez" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

View File

@ -56,12 +56,10 @@
<properties>
<hibernate-core.version>5.4.7.Final</hibernate-core.version>
<h2.version>1.4.200</h2.version>
<commons-lang3.version>3.8.1</commons-lang3.version>
<maven.deploy.skip>true</maven.deploy.skip>
<spring-boot.version>2.1.7.RELEASE</spring-boot.version>
<hibernate.core.version>5.4.7.Final</hibernate.core.version>
<h2.version>1.4.200</h2.version>
<commons.lang3.version>3.8.1</commons.lang3.version>
<geodb.version>0.9</geodb.version>
</properties>

View File

@ -40,6 +40,7 @@
<modules>
<module>parent-java</module>
<module>testing</module>
<module>toolkits</module>
<module>xml</module>
</modules>
@ -73,13 +74,17 @@
<tomcat-jdbc.version>7.0.42</tomcat-jdbc.version>
<ehcache.version>2.6.8</ehcache.version>
<hsqldb.version>2.3.2</hsqldb.version>
<h2.version>1.4.200</h2.version>
<!-- DATA STRUCTURES -->
<jackson.version>2.12.4</jackson.version>
<!-- TEST -->
<junit4.version>4.13.2</junit4.version>
<junit5.version>5.7.0</junit5.version>
<junit5.version>5.8.1</junit5.version>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
<junit-platform.version>1.8.1</junit-platform.version>
<junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version>
<mockito-core.version>3.12.4</mockito-core.version>
<hamcrest.version>2.2</hamcrest.version>
<hamcrest-all.version>1.3</hamcrest-all.version>

View File

@ -4,7 +4,7 @@
- [Get the Path of the /src/test/resources Directory in JUnit](https://www.baeldung.com/junit-src-test-resources-directory-path)
- [Tagging and Filtering JUnit Tests](https://www.baeldung.com/junit-filtering-tests)
- [JUnit 5 Temporary Directory Support](https://www.baeldung.com/junit-5-temporary-directory)
- [@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll](http://www.baeldung.com/junit-before-beforeclass-beforeeach-beforeall)
- [Junit 4 的 @Before 和 @BeforeClass 对比 Junit 5 @BeforeEach 和 @BeforeAll](https://www.ossez.com/t/junit-4-before-beforeclass-junit-5-beforeeach-beforeall/13819)
- [JUnit 5 @Test Annotation](http://www.baeldung.com/junit-5-test-annotation)
- [Migrating from JUnit 4 to JUnit 5](http://www.baeldung.com/junit-5-migration)
- [Assert an Exception is Thrown in JUnit 4 and 5](http://www.baeldung.com/junit-assert-exception)

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -21,7 +22,8 @@ public class BeforeEachAndAfterEachAnnotationsUnitTest {
private List<String> list;
@BeforeEach
@BeforeEach
public void init() {
LOG.info("startup");
list = new ArrayList<>(Arrays.asList("test1", "test2"));