-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error details reported via Platform.io #22
Comments
Note that I get errors when |
Hi.. How are you running it ? Can you please paste the output you get ? |
Running it via the Test button in VSC, haven't tried the cli directly although the button just invokes the cli in a terminal. I'll post an example later when I'm at my PC |
Repro:
Platformio.ini
Run:
Output:
So its correct that its failed, because Would be great if the output showed what was wrong as the debugging cycle is laborious Thanks! |
Actaully, I think its simply because an exception is being thrown and PlatformIO/Unity aren't outputting anything useful. https://community.platformio.org/t/getting-output-of-failed-test/10940 |
I've hit a similar issue and it looks like PlatformIO now outputs the error code from the failing test. In my case, when I forget to mock an Arduino method I get a seg fault: Program errored with 3221225477 code |
Running your tests with Example failing test
---------------------------------------------------------------------
test/test-example.cpp:43
.....................................................................
test/test-example.cpp:43: FAILED:
due to unexpected exception with message:
Unknown exception This at least gives you some information in that the test that failed was declared on line 43 of This still wasn't enough for me, so I patched #include "fakeit/fakeit.hpp" with #ifndef ARDUINOFAKE_CUSTOM_FAKEIT
#include "fakeit/fakeit.hpp"
#else
#include "custom-fakeit.hpp"
#endif // ARDUINOFAKE_CUSTOM_FAKEIT I edited [env:native]
platform=native
lib_extra_dirs=
./test_includes
build_flags=
-DARDUINOFAKE_CUSTOM_FAKEIT
-Wno-deprecated ; Hide errors related to fakeit
lib_deps=
fabiobatsilva/ArduinoFake@^0.3.1 I then created a Again, inside This then gives a little more output on error: Unknown file:0: FAILED:
explicitly with message:
Unexpected method invocation: unknown()
An unmocked method was invoked. All used virtual methods must be stubbed! Annoyingly FakeIt cannot provide you with the name of the method that you tried to call as, if it hasn't been mocked yet, it cannot possibly know its name due to the compiled nature of the code and C++'s lack of support for reflection. Helpfully, if it is a method that you have mocked, but perhaps using Unknown file:0: FAILED:
explicitly with message:
Unexpected method invocation: ArduinoFake().digitalWrite(
, )
Could not find any recorded behavior to support this method call. It would be nice if all of the |
Following on from the above I edited #define _ArduinoFakeInstanceGetter1(mock) \
mock##Fake* mock() \
{ \
if (!this->Instances->mock){ \
this->Instances->mock = &this->Mocks->mock.get(); \
mock##Fake::prepare(this->Mocks->mock); \
} \
return this->Instances->mock; \
} This adds a call to each Interface that we're mocking to prepare the mock with known methods - this allows FakeIt to known the names of any methods that haven't been called. This requires a static void prepare(Mock<FunctionFake> &functionFakeMock) {
Method(functionFakeMock, init);
Method(functionFakeMock, loop);
Method(functionFakeMock, setup);
Method(functionFakeMock, pinMode);
Method(functionFakeMock, digitalWrite);
Method(functionFakeMock, digitalRead);
Method(functionFakeMock, analogRead);
Method(functionFakeMock, analogReference);
Method(functionFakeMock, analogWrite);
Method(functionFakeMock, millis);
Method(functionFakeMock, micros);
Method(functionFakeMock, delay);
Method(functionFakeMock, delayMicroseconds);
Method(functionFakeMock, pulseIn);
Method(functionFakeMock, pulseInLong);
Method(functionFakeMock, shiftOut);
Method(functionFakeMock, shiftIn);
Method(functionFakeMock, detachInterrupt);
Method(functionFakeMock, attachInterrupt);
Method(functionFakeMock, cli);
Method(functionFakeMock, sei);
Method(functionFakeMock, tone);
Method(functionFakeMock, noTone);
OverloadedMethod(functionFakeMock, random, long(long));
OverloadedMethod(functionFakeMock, random, long(long, long));
Method(functionFakeMock, randomSeed);
Method(functionFakeMock, map);
Method(functionFakeMock, yield);
} This then gives you quite a useful message without having to do any mocking in the tests themselves, for example: Unknown file:0: FAILED:
explicitly with message:
Unexpected method invocation: functionFakeMock.digitalWrite(
, )
Could not find any recorded behavior to support this method call. For some methods you actually get a really nice message with the exact parameters passed, Unknown file:0: FAILED:
explicitly with message:
Unexpected method invocation: functionFakeMock.delay(40)
Could not find any recorded behavior to support this method call. If anyone is better at macros than me I'm sure this could be significantly simplified |
@r89m, Thanks for looking into it.. that looks promising. The "fakeit/fakeit.hpp" file is just a directly copy of the the standalone version of https://github.com/eranpeer/FakeIt. We should be able to upgrade to the latest version.. |
Upgrading to the latest I happen to use |
I have a failing test - because I haven't mocked/faked all the Arduino bits fully.
When I run the tests I get a
Failed
(correctly) reported for the test, but theres no error details. Should there be?I have to debug each time to find which thing I've not mocked/faked properly.
I'm new to both PlatformIO and ArduinoFake
Any help much appreciated!
platformIO.ini snippet:
The text was updated successfully, but these errors were encountered: