If you just want to test the STDOUT via a test case, I think CaptureIO can be used. The following has the spec and sample code.
https://hexdocs.pm/ex_unit/master/ExUnit.CaptureIO.html
You could mock the method calls using some mocking libraries, but for STDOUT, the above one would be simpler approach.