こんにちは私は、を返すメソッドをテストしようとしていますArrayList
がjunit 4 framework
、指定したテストでフリーズします。テスト
@Test
public void testInDebt() {
AdminController cont = new AdminController();
Apartment o1 = new Apartment(1, 4, "Maier B", true);
Apartment o2 = new Apartment(1, 4, "Maier B", false);
ArrayList<Expense> exp = new ArrayList<>();
cont.addKeyWithList(o2, exp);
assertEquals(exp, cont.inDebt()); <<<<<< Problem here when I call inDebt
//
// cont.addKeyWithList(o1, exp);
// assertFalse(cont.inDebt().isEmpty());
}
Repo.class
public ArrayList<String> inDebt(){
ArrayList<String> inDebt = new ArrayList<>();
for (Map.Entry<Apartment, ArrayList<Expense>> entry : mp.entrySet() ) {
if(entry.getKey().isDebt()){ // Flag like method on the key if there are debts.
// System.out.println("Key = " + entry.getKey() + ", Object = " + entry.getValue());
inDebt.add(entry.getKey().getOwner());
}
}
return inDebt;
}
Controller.class
@Override
public ArrayList<String> inDebt() {
return repo.inDebt();
}
スタックトレース
proj_individual [JUnit]
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner at localhost:24285
Thread [main] (Suspended (entry into method inDebt in AdminController))
AdminController.inDebt() line: 24
AdminControllTests.testInDebt() line: 75
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
FrameworkMethod$1.runReflectiveCall() line: 45
FrameworkMethod$1(ReflectiveCallable).run() line: 15
FrameworkMethod.invokeExplosively(Object, Object...) line: 42
InvokeMethod.evaluate() line: 20
BlockJUnit4ClassRunner(ParentRunner<T>).runLeaf(Statement, Description, RunNotifier) line: 263
BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 68
BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 47
ParentRunner$3.run() line: 231
ParentRunner$1.schedule(Runnable) line: 60
BlockJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) line: 229
ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 50
ParentRunner$2.evaluate() line: 222
BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 300
JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) line: 50
TestExecution.run(ITestReference[]) line: 38
RemoteTestRunner.runTests(String[], String, TestExecution) line: 467
RemoteTestRunner.runTests(TestExecution) line: 683
RemoteTestRunner.run() line: 390
RemoteTestRunner.main(String[]) line: 197
Thread [ReaderThread] (Running)
C:\Program Files\Java\jre7\bin\javaw.exe (Dec 18, 2012 8:00:03 PM)