Skip to content

Commit

Permalink
Add some output to tests as they run.
Browse files Browse the repository at this point in the history
  • Loading branch information
J08nY committed Apr 25, 2024
1 parent bc4b360 commit ee5c50d
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ private String testString(Test t, String prefix, int index) {
return line + out.toString();
}

@Override
public void beginTest(Test t) {
if (t instanceof CompoundTest) {
CompoundTest test = (CompoundTest) t;
} else {
SimpleTest<? extends BaseTestable> test = (SimpleTest<? extends BaseTestable>) t;
}
output.print("Running ▶ " + t.getDescription());
output.flush();
}


@Override
public void endTest(Test t) {
output.print("\33[2K\r");
}

@Override
public void outputTest(Test t, int index) {
if (!t.hasRun())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ private Element testElement(Test t, int index) {
return testElem;
}

@Override
public void beginTest(Test t) {

}

@Override
public void endTest(Test t) {

}

@Override
public void outputTest(Test t, int index) {
if (!t.hasRun())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ private Map<String, Object> testObject(Test t, int index) {
return testObj;
}

@Override
public void beginTest(Test t) {

}

@Override
public void endTest(Test t) {

}

@Override
public void outputTest(Test t, int index) {
if (!t.hasRun())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ public void begin(TestSuite suite) {
}
}

@Override
public void beginTest(Test t) {
for (TestWriter writer : writers) {
writer.beginTest(t);
}
}

@Override
public void endTest(Test t) {
for (TestWriter writer : writers) {
writer.endTest(t);
}
}

@Override
public void outputTest(Test t, int index) {
for (TestWriter writer : writers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,32 @@ public interface TestWriter {
void begin(TestSuite suite);

/**
* @param t
* @param index
* Begin the test (before it is run).
* @param t Test to begin output of.
*/
void beginTest(Test t);

/**
* End the test (after it is run, or errored out).
* @param t Test to end output of.
*/
void endTest(Test t);

/**
* @param t Test to output.
* @param index Index of the test.
*/
void outputTest(Test t, int index);

/**
* @param t
* @param cause
* @param index
* @param t Test to output the error from.
* @param cause Throwable to output.
* @param index Index of the test.
*/
void outputError(Test t, Throwable cause, int index);

/**
*
* End writing the TestSuite.
*/
void end();
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public void run(int from, int to) {
*/
protected <T extends Test> T runTest(T t) {
running = t;
writer.beginTest(t);
t.run();
writer.endTest(t);
running = null;
return t;
}
Expand Down

0 comments on commit ee5c50d

Please sign in to comment.