tymonx / utest

Lightweight unit testing framework for C/C++ projects. Suitable for embedded devices.
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

Documentation #2

Open mrdimfox opened 5 years ago

mrdimfox commented 5 years ago

I love your test util. It looks very great. But I have no idea how to use it! Can you write some docs, not only about a compiling but using the library for a testing?

For example, I want to redirect an output from stdout to ITM (it is much faster than a semihosting). How can I do it? Can I implement my own "TestWriter" or something? How can I pass it as an argument to TestRunner?

mmwebster commented 5 years ago

Not sure if you're still interested but you can implement something like this for a custom writer. My full source is here.

class UartWriter final : public utest::TestWriter {
  public:
    UartWriter(cal::Uart* uart) noexcept;

  private:
    virtual void write(const utest::TestString& str) noexcept override;

    virtual void color(utest::TestColor c) noexcept override;

    cal::Uart* m_uart;
};

I'm running into an issue though where my tests are run twice.

mrdimfox commented 5 years ago

@mmwebster Hmm. Yes, thank you! That looks like exactly I want to.