应用程序 classes/methods 如何可用于 java 测试
How are application classes/methods made available to java tests
在我最近的角色中,我从 C 过渡到 Java。我们的项目具有 Apache Maven 制定的标准 java 项目结构。我能够 运行 从 Intellij 进行 Junit 测试没有任何问题。
但我很好奇 /src/main/ 中的应用程序逻辑如何可用于 /src/test 中的测试逻辑。
单元测试框架对此负责吗?或构建工具创建一个临时 jar,其中包括测试 类 以及应用程序 类 由它们各自的包结构管理?
感谢您的回复!
But I am curious about how the application logic spread across /src/main/ is made available to the test logic in /src/test.
Is Unit testing framework responsible for this?
没有
or build tool creates a temporary jar which includes test classes
along with application classes as governed by their respective package
structures?
您可以配置一个构建来创建一个临时 jar 文件,其中包含测试 类 以及应用程序 类,但这不是正常的事情。通常,构建工具(在您的例子中是 Maven)会将所有代码编译为 .class
文件,并在测试为 运行 时将所有这些 .class
文件放在 CLASSPATH 中。当测试为 运行.
时,CLASSPATH 上可用的所有 类 都可以在测试中访问
在我最近的角色中,我从 C 过渡到 Java。我们的项目具有 Apache Maven 制定的标准 java 项目结构。我能够 运行 从 Intellij 进行 Junit 测试没有任何问题。
但我很好奇 /src/main/ 中的应用程序逻辑如何可用于 /src/test 中的测试逻辑。
单元测试框架对此负责吗?或构建工具创建一个临时 jar,其中包括测试 类 以及应用程序 类 由它们各自的包结构管理?
感谢您的回复!
But I am curious about how the application logic spread across /src/main/ is made available to the test logic in /src/test.
Is Unit testing framework responsible for this?
没有
or build tool creates a temporary jar which includes test classes along with application classes as governed by their respective package structures?
您可以配置一个构建来创建一个临时 jar 文件,其中包含测试 类 以及应用程序 类,但这不是正常的事情。通常,构建工具(在您的例子中是 Maven)会将所有代码编译为 .class
文件,并在测试为 运行 时将所有这些 .class
文件放在 CLASSPATH 中。当测试为 运行.