eclipse-iceoryx / eclipse-iceoryx/iceoryx
Refactor `ErrorHandlerMock`
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 492
- Avg merge
- 18h 57m
- Merged PRs (30d)
- 1
Description
## Brief feature description
Working with the `ErrorHandlerMock` currently requires some boiler plate code. The code and usage shall be simplified.
## Detailed information
From this [comment](https://github.com/eclipse-iceoryx/iceoryx/pull/1170#discussion_r837738763):
It is always the same procedure
1. set the temporary error handler
1. store the error code and an error detected flag
1. check for the error detected and error code
Let's assume we have something like this
```cpp
auto errorHandlerMock = iox::ErrorHandlerMock;
// do something to trigger the error
ASSERT_TRUE(errorHandlerMock.hasError());
EXPECT_THAT(errorHandlerMock.getError(), Eq(iox::PoshError::Foo)); // assuming we keep the `NO_ERROR`, we could essentially skip the hasError call
EXPECT_THAT(errorHandlerMock.getErrorLevel(), Eq(iox::ErrorLevel::SEVERE));
```
The `ErrorHandlerMock` dtor could terminate if `hasError` is not called, to ensure that the check is done.
Contributor guide
Research direction
Start by locating the ErrorHandlerMock definition and its existing tests, then read the referenced discussion in PR 1170. Compare the current setup, error, and verification flow with the proposed hasError, getError, and getErrorLevel API. Done means the mock usage is simplified and its tests cover whether errors and levels are checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100