Elixir check if a function has been called from a ExUnit test?

Stratus3D

Is there a way to check if a function has been called from a ExUnit test case? I have a function that calls IO.puts and I would like to test and verify that something is being outputted to STDOUT via a test case.

I saw this: http://erlang.org/pipermail/erlang-questions/2005-July/016259.html. But I was hoping there might be a simpler way of doing this with ExUnit.

Is there a way to check and see if my function calls IO.puts? Or at least check and see if something has been sent to STDOUT?

parroty

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Check if the function has been called in gtest

From Dev

How can I check if an anonymous function has been called with NSubstitute?

From Dev

Check the conditions every time after function has been called

From Dev

sinon spy check if function has been called error

From Dev

Scheme: How to check if a function has been called with a same argument

From Dev

How to test that a function has been called after an event was fired?

From Java

How can I test that a function has not been called?

From Dev

How to test how many times a function has been called

From Dev

How to test how many times a function has been called

From Dev

AngularJS unit test check if function without methods have been called

From Dev

Test if join has been called

From Dev

Test if method in ClassA has been called from another method in ClassA

From Dev

How to check if a certain method has been called?

From Dev

Nsubstitute check if setter has been called

From Dev

Check if redux action has been called with enzyme

From Dev

AngularJS test if $scope method has been called

From Dev

AngularJS test if $scope method has been called

From Dev

Elixir ExUnit: module under test is not available

From Dev

How to check how many times a recursive function has been called in Java?

From Dev

What is the canonical way to check if a function has been called in Python unittest without use of a mock?

From Dev

How to check how many times a recursive function has been called in Java?

From Dev

How to determine if a function has been called in Powershell

From Dev

Jquery function which is added from html and div that has been called from php on webpage is not working properly

From Dev

A function to check if a file has been changed

From Dev

Why is a jQuery function still called once the class or id used as the selector has been removed from the HTML?

From Dev

Why is a jQuery function still called once the class or id used as the selector has been removed from the HTML?

From Dev

Are guards to check if a method has been called optimized by Java?

From Dev

Perl: How to check if CGI::header has already been called?

From Dev

Check in PHP if date_default_timezone_set() has been called

Related Related

  1. 1

    Check if the function has been called in gtest

  2. 2

    How can I check if an anonymous function has been called with NSubstitute?

  3. 3

    Check the conditions every time after function has been called

  4. 4

    sinon spy check if function has been called error

  5. 5

    Scheme: How to check if a function has been called with a same argument

  6. 6

    How to test that a function has been called after an event was fired?

  7. 7

    How can I test that a function has not been called?

  8. 8

    How to test how many times a function has been called

  9. 9

    How to test how many times a function has been called

  10. 10

    AngularJS unit test check if function without methods have been called

  11. 11

    Test if join has been called

  12. 12

    Test if method in ClassA has been called from another method in ClassA

  13. 13

    How to check if a certain method has been called?

  14. 14

    Nsubstitute check if setter has been called

  15. 15

    Check if redux action has been called with enzyme

  16. 16

    AngularJS test if $scope method has been called

  17. 17

    AngularJS test if $scope method has been called

  18. 18

    Elixir ExUnit: module under test is not available

  19. 19

    How to check how many times a recursive function has been called in Java?

  20. 20

    What is the canonical way to check if a function has been called in Python unittest without use of a mock?

  21. 21

    How to check how many times a recursive function has been called in Java?

  22. 22

    How to determine if a function has been called in Powershell

  23. 23

    Jquery function which is added from html and div that has been called from php on webpage is not working properly

  24. 24

    A function to check if a file has been changed

  25. 25

    Why is a jQuery function still called once the class or id used as the selector has been removed from the HTML?

  26. 26

    Why is a jQuery function still called once the class or id used as the selector has been removed from the HTML?

  27. 27

    Are guards to check if a method has been called optimized by Java?

  28. 28

    Perl: How to check if CGI::header has already been called?

  29. 29

    Check in PHP if date_default_timezone_set() has been called

HotTag

Archive