Skip to content

Recommendation for Unit Testing? #644

Answered by ArthurSonzogni
daners88 asked this question in Q&A
Discussion options

You must be logged in to vote

FTXUI should be quite easy to test, because you can send arbitrary events to a component, and check how it ends up affecting the UI state. The UI state is mainly stored from outside of FTXUI.

You can take example from pre-existing FTXUI tests:
https://github.com/ArthurSonzogni/FTXUI/blob/main/src/ftxui/component/input_test.cpp

It boiles down to:

  State myState;
  Component myComponent = Mycomponent(&myState);

  myComponent->OnEvent(Event::Character("a"));
  EXPECT_EQ(myState, expected)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cma0014
Comment options

Answer selected by ArthurSonzogni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants