\n我的 Appium + JUnit 测试在本地工作得很好,但在 aws 上找不到属性文件。我的测试位于 下src/test/java,测试中使用的属性文件位于src/test/resources/locale. \n包含依赖项内容的压缩包:
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app-0.1-tests.jar\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app-0.1.jar\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 dependency-jars \n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ...\nRun Code Online (Sandbox Code Playgroud)\n\napp-0.1-tests.jar内容:
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 META-INF\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 MANIFEST.MF\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 maven\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ....\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 com\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ....\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 locale\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 en_EN.properties\nRun Code Online (Sandbox Code Playgroud)\n\n不幸的是,当我尝试加载属性文件时,出现 IOException - 文件未在以下位置找到:\nfile:/tmp/scratchcC4yMz.scratch/test-packagefQ2euI/app-0.1-tests.jar!/locale/en_EN.properties
每次遇到同样的问题时,我都尝试通过多种方式加载它们。在当地,一切都很有魅力。代码示例:
\n\nFile file = new File(ClassName.class.getResource("/locale/en_EN.properties").getPath());\ntry (InputStream inputStream = new FileInputStream(file.getPath());\nInputStreamReader streamReader = new InputStreamReader(inputStream, Charset.forName("UTF-8"))) {\n Properties properties = new Properties();\n properties.load(streamReader);\n return properties;\n} catch (IOException e) {\n System.err.println("Properties file not found: …Run Code Online (Sandbox Code Playgroud)