在哪里存储二进制文件以用于单元测试 [英] Where to store a binary file to be used for unit testing
问题描述
我应该在哪里存储用于单元测试的资源(本例中为二进制文件)?
Where should I store a resource (binary file in my case) that I need to use for unit testing?
具体地说,我的目录结构是标准的:
Specifically, my directory structure is a standard:
src -> main -> java -> com.company.project -> classes...
-> test -> java -> com.company.project -> classes...
我想模拟正在从文件系统读取的文件,并将其替换为项目中的文件.
I want to mock a file being read from the file system and replace it with a file from within my project.
推荐答案
src\test\resources
是存放单元测试所需资源的好地方.
src\test\resources
is a good place for resources you need for unit-testing, if you are using mavens standard directory layout.
在此处了解有关不同目录的更多信息: https://maven.apache.org/guides /introduction/introduction-to-the-standard-directory-layout.html
Read more about the different directories here: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
这篇关于在哪里存储二进制文件以用于单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!