Open cdprete opened 2 years ago
Hi! What testing framework do you use? JUnit4? JUnit5? Spock? TestNG?
I put up an example project that shows how to use the MockTextTerminal with JUnit 5.
Hi. I'm using JUnit 5, but even JUnit 4 is fine if for you is better (I can convert the code accordingly).
Did you see the example project I put up yesterday?
Sorry, I read just the comment about the test framework and I missed the next one ;) I'll have a look at it.
Thank you.
Hi. I can confirm the example works, but how to test prompt properties? For example, that a proper color is set?
Nevermind. I can of course fetch the properties and assert that they're there.
Hi.
I've just realized I cannot really assert what properties have been set when using executeWithPropertiesConfigurator
.
Do you have any way to test this?
Edit: For now, I've come up with
@Override
public void executeWithPropertiesConfigurator(Consumer<TerminalProperties<?>> propertiesConfigurator, Consumer<TextTerminal<MockTextTerminal>> action) {
final Consumer<TerminalProperties<?>> propertiesHolder = terminalProperties -> {
propertiesConfigurator.accept(terminalProperties);
lastUsedProperties = new TerminalProperties<>(this);
terminalProperties.getAllKeys().forEach(key -> lastUsedProperties.put(key, terminalProperties.getString(key)));
};
super.executeWithPropertiesConfigurator(propertiesHolder, action);
}
which works but it's not super nice (and not thread safe).
Hi. Can you please provide some documentation or guidance on how to use the MockTextTerminal? I would like to unit-test my business logic and the example in the repository with the Robot is not really adequate for unit tests (given the definition of unit test).
Kind regards and thanks in advance.