@Test public void returnsZeroIfTheTerminalOutputIsNotCorrect() throws Exception { givenTheAppPIDIs(ANY_PID); givenTheTerminalReturnsAnError(); int usage = cpu.getUsage(); assertEquals(0, usage); }
public int getUsage() { try { String result = terminal.exec("top -s cpu -n 1"); int cpuUsage = extractCPUUsage(result); return cpuUsage; } catch (IOException e) { Logger.e("Exception catch while reading the CPU usage", e); return 0; } }
CPU { public int getUsage() { try { String result = terminal.exec("top -s cpu -n 1"); int cpuUsage = extractCPUUsage(result); return cpuUsage; } catch (IOException e) { Logger.e("Exception catch while reading the CPU usage", e); return 0; } } }
CPU { public int getUsage() { try { String result = terminal.exec("top -s cpu -n 1"); int cpuUsage = extractCPUUsage(result); return cpuUsage; } catch (IOException e) { Logger.e("Exception catch while reading the CPU usage", e); return 0; } } CPU(App app, Terminal terminal); }
CPU { public int getUsage() { try { String result = terminal.exec("top -s cpu -n 1"); int cpuUsage = extractCPUUsage(result); return cpuUsage; } catch (IOException e) { Logger.e("Exception catch while reading the CPU usage", e); return 0; } } CPU(App app, Terminal terminal); int getUsage(); }
CPU { public int getUsage() { try { String result = terminal.exec("top -s cpu -n 1"); int cpuUsage = extractCPUUsage(result); return cpuUsage; } catch (IOException e) { Logger.e("Exception catch while reading the CPU usage", e); return 0; } } CPU(App app, Terminal terminal); int getUsage();  }