【发布时间】:2020-01-23 08:42:14
【问题描述】:
在使用 Junit 进行测试时,我似乎无法运行此测试。它只在失败跟踪中显示错误和“java.lang.ArrayStoreException”。如果有人能解决我的问题,那将是一个很大的帮助。 LinkedInUser 是我做的一个对象,getConnections 方法返回一个List<LinkedInUser> 数据类型。
@Test
public void testSort() throws LinkedInException {//Test sorting
LinkedInUser user0 = new LinkedInUser("Han", null);
LinkedInUser user1 = new LinkedInUser("LUKE", null);
LinkedInUser user2 = new LinkedInUser("leia", null);
user0.addConnection(user1);//Han gets 2 connections
user0.addConnection(user2);
List<LinkedInUser> friends = user0.getConnections();//Transfer to array
Collections.sort(friends);//Sort
Assert.assertEquals(user2, friends.get(0));//Compare
Assert.assertEquals(user1, friends.get(1));
}
【问题讨论】:
-
请edit您的问题提供错误的堆栈跟踪。提供minimal reproducible example 来演示问题也是有益的。
-
您能否也发布以下内容:1.
LinkedInUser和LinkedInException类 2. 堆栈跟踪