mirror of
https://github.com/revanced/jadb.git
synced 2025-02-14 02:56:48 +01:00
better assert messages on unit test fail
This commit is contained in:
parent
081154ee1e
commit
fd1a833e6d
@ -186,10 +186,18 @@ public class FakeAdbServer implements AdbResponder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void verifyExpectations() {
|
public void verifyExpectations() {
|
||||||
org.junit.Assert.assertEquals(0, fileExpectations.size());
|
for (FileExpectation expectation : fileExpectations) {
|
||||||
org.junit.Assert.assertEquals(0, shellExpectations.size());
|
org.junit.Assert.fail(expectation.toString());
|
||||||
org.junit.Assert.assertEquals(0, listExpectations.size());
|
}
|
||||||
org.junit.Assert.assertEquals(0, tcpipExpectations.size());
|
for (ShellExpectation expectation : shellExpectations) {
|
||||||
|
org.junit.Assert.fail(expectation.toString());
|
||||||
|
}
|
||||||
|
for (ListExpectation expectation : listExpectations) {
|
||||||
|
org.junit.Assert.fail(expectation.toString());
|
||||||
|
}
|
||||||
|
for (int expectation : tcpipExpectations) {
|
||||||
|
org.junit.Assert.fail("Expected tcp/ip on" + expectation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FileExpectation implements ExpectationBuilder {
|
private static class FileExpectation implements ExpectationBuilder {
|
||||||
@ -233,6 +241,11 @@ public class FakeAdbServer implements AdbResponder {
|
|||||||
public void returnFile(ByteArrayOutputStream buffer) throws IOException {
|
public void returnFile(ByteArrayOutputStream buffer) throws IOException {
|
||||||
buffer.write(content);
|
buffer.write(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Expected file " + path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShellExpectation {
|
public static class ShellExpectation {
|
||||||
@ -254,6 +267,11 @@ public class FakeAdbServer implements AdbResponder {
|
|||||||
public void writeOutputTo(DataOutputStream stdout) throws IOException {
|
public void writeOutputTo(DataOutputStream stdout) throws IOException {
|
||||||
stdout.write(this.stdout);
|
stdout.write(this.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Expected shell " + command;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ListExpectation {
|
public static class ListExpectation {
|
||||||
@ -283,6 +301,11 @@ public class FakeAdbServer implements AdbResponder {
|
|||||||
return Collections.unmodifiableList(files);
|
return Collections.unmodifiableList(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Expected file list " + remotePath;
|
||||||
|
}
|
||||||
|
|
||||||
private static class MockFileEntry extends RemoteFile {
|
private static class MockFileEntry extends RemoteFile {
|
||||||
|
|
||||||
private final int size;
|
private final int size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user