小编Sha*_*702的帖子

Maven没有看到我在单元测试中使用的一些文本文件

我正在用maven弄湿我的脚,但这是一个陡峭的学习曲线.我正在尝试从单元测试中加载纯文本文件.测试通过,现在我已经将项目转换为maven项目,测试似乎无法解决测试文件的位置.


// I have the following test that I would like to run:

package net.stevenpeterson.base;

import static org.junit.Assert.*;

import net.stevenpeterson.base.LoadStringUtility;

import org.junit.Test;

public class LoadStringUtilityTest {

    @Test
    public void testSingleLine() {
        assertEquals("Loading File", "This is a test." , loadFile("singleLine") );
    }

    @Test
    public void testSeveralLines() {
        assertFalse("Compare a string appended with extra lines, should not compare true. ", "This is a test.".equals(loadFile("severalLines")) );
    }

    @Test
    public void loadSherlockHolmes() {
        String fileToLoad = "cano.txt";
        try{
        StringBuilder holmesCanon = LoadStringUtility.LoadString(fileToLoad);

        System.out.println("Finished Loading …
Run Code Online (Sandbox Code Playgroud)

java junit pom.xml maven

2
推荐指数
1
解决办法
4820
查看次数

标签 统计

java ×1

junit ×1

maven ×1

pom.xml ×1