Java – test data directory using JUnit
•
Java
I'm writing some JUnit tests that rely on data files Where should these data files be placed? How will I get the location of this directory (in the JUnit test)@ H_ 301_ 2 @ in Python, I'll use something like:
datadir = os.dirname(__file__) + "/data/"
Solution
It depends on the content of the data file you use, but generally, just create a package and make sure it's on your classpath To load the property file from the "data" package, add the "mydata. Props" file. You can use to load the property file, such as:
this.getClass().getClassLoader().getResourceAsStream("/data/MyData.props");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码