我正在尝试使用ScalaTest(使用Scala 2.11.0和SBT 0.13.x)为包含许多子项目的项目生成单个HTML报告.为此,我在build.sbt中添加以下行:
testOptions in ThisBuild += Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/test-reports")
Run Code Online (Sandbox Code Playgroud)
我已经包含了该设施所需的pegdown库...
libraryDependencies in ThisBuild ++= Seq(
"org.scalatest" %% "scalatest" % "2.1.7" % "test",
"org.pegdown" % "pegdown" % "1.4.2" % "test"
)
Run Code Online (Sandbox Code Playgroud)
当我执行我的测试时,测试输出的index.html文件会相互覆盖,因此最后执行的任何一个"胜利",其他测试不会出现在索引中.
我想要实现的输出类似于unidoc的输出.Unidoc可以创建一组跨越子项目的HTML ScalaDoc文件.
有可能做我在这里尝试的事情吗?我的问题是ScalaTest还是SBT?
为了使情况更加清晰,我创建了一个github项目来演示影响(并且同时嵌入了unidoc和ScalaTest):
https://github.com/MartinSnyder/scalatest-multiproject-example
我最近遇到了一个表面看起来不正确的比较器.但是,我一直无法得到一个输入,导致比较器产生错误的结果.
如果o1 <= o2,它会错误地将值视为相等,如果o1> o2则正确返回1.
我试图在下面尽可能地简化场景.任何人都可以:
我已经尝试了很多,我正在扯皮!
package comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class BadComparator implements Comparator<Integer>
{
public int compare(Integer o1, Integer o2)
{
// Generally Accepted implementation
//return o1 - o2;
// Incorrect(?) Implementation
return (o2 < o1) ? 1 : 0;
}
public static void main(String[] args)
{
List<Integer> intList = Arrays.asList(10, 9, 8, 1, 2, 3, 7, 4, 5, 6);
Collections.sort(intList, new BadComparator());
System.out.println(intList);
}
}
Run Code Online (Sandbox Code Playgroud) 我最近在重构代码时遇到了这个问题:
下面的方法"getList()"具有参数化的返回类型.在下面,我已经放了三个试图隐式绑定的<T>方法<Integer>.
我无法弄清楚为什么前两个编译和运行正确,而第三个(bindViaMethodInvocation)甚至不会编译.
有线索吗?
在StackOverflow上寻找类似的问题时,我遇到了这个问题: 返回类型的推断通配符泛型.那里的答案(信用Laurence Gonsalves)有几个有用的参考链接来解释应该发生的事情: "这里的问题(正如你的建议)是编译器正在执行捕获转换.我相信这是结果JLS的JLS 的§15.12.2.6."
package stackoverflow;
import java.util.*;
public class ParameterizedReturn
{
// Parameterized method
public static <T extends Object> List<T> getList()
{
return new ArrayList<T>();
}
public static List<Integer> bindViaReturnStatement()
{
return getList();
}
public static List<Integer> bindViaVariableAssignment()
{
List<Integer> intList = getList();
return intList;
}
public static List<Integer> bindViaMethodInvocation()
{
// Compile error here
return echo(getList());
}
public static List<Integer> …Run Code Online (Sandbox Code Playgroud)