Clearing HasFailure flag in gtest
up vote
1
down vote
favorite
I have a Unit Test which is used to test if a function works well over a series of input:
TEST_F( something, something) {
std::vector<int> inputFileNumber = { 0, 1 , 2, 3 };
for(auto i : inputFileNumber ) {
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
logIfHasFailure(i);
}
}
I would like to know which of the inputs are failing, so I could use ::testing::Test::HasFailure. Unfortunately, once the flag is set, I cannot clear it and all the following indexes are logged as well.
Any ideas?
c++ googletest
add a comment |
up vote
1
down vote
favorite
I have a Unit Test which is used to test if a function works well over a series of input:
TEST_F( something, something) {
std::vector<int> inputFileNumber = { 0, 1 , 2, 3 };
for(auto i : inputFileNumber ) {
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
logIfHasFailure(i);
}
}
I would like to know which of the inputs are failing, so I could use ::testing::Test::HasFailure. Unfortunately, once the flag is set, I cannot clear it and all the following indexes are logged as well.
Any ideas?
c++ googletest
What doeslogIfHasFailure()
do? Does it print to the console or to some log file? Why is print fromEXPECT_NEAR
not sufficient?
– Yksisarvinen
Nov 21 at 15:02
logIfHasFailure logs a message "data i has failed"
– HAL9000
Nov 21 at 15:08
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a Unit Test which is used to test if a function works well over a series of input:
TEST_F( something, something) {
std::vector<int> inputFileNumber = { 0, 1 , 2, 3 };
for(auto i : inputFileNumber ) {
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
logIfHasFailure(i);
}
}
I would like to know which of the inputs are failing, so I could use ::testing::Test::HasFailure. Unfortunately, once the flag is set, I cannot clear it and all the following indexes are logged as well.
Any ideas?
c++ googletest
I have a Unit Test which is used to test if a function works well over a series of input:
TEST_F( something, something) {
std::vector<int> inputFileNumber = { 0, 1 , 2, 3 };
for(auto i : inputFileNumber ) {
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
logIfHasFailure(i);
}
}
I would like to know which of the inputs are failing, so I could use ::testing::Test::HasFailure. Unfortunately, once the flag is set, I cannot clear it and all the following indexes are logged as well.
Any ideas?
c++ googletest
c++ googletest
asked Nov 21 at 14:27
HAL9000
2,1571538
2,1571538
What doeslogIfHasFailure()
do? Does it print to the console or to some log file? Why is print fromEXPECT_NEAR
not sufficient?
– Yksisarvinen
Nov 21 at 15:02
logIfHasFailure logs a message "data i has failed"
– HAL9000
Nov 21 at 15:08
add a comment |
What doeslogIfHasFailure()
do? Does it print to the console or to some log file? Why is print fromEXPECT_NEAR
not sufficient?
– Yksisarvinen
Nov 21 at 15:02
logIfHasFailure logs a message "data i has failed"
– HAL9000
Nov 21 at 15:08
What does
logIfHasFailure()
do? Does it print to the console or to some log file? Why is print from EXPECT_NEAR
not sufficient?– Yksisarvinen
Nov 21 at 15:02
What does
logIfHasFailure()
do? Does it print to the console or to some log file? Why is print from EXPECT_NEAR
not sufficient?– Yksisarvinen
Nov 21 at 15:02
logIfHasFailure logs a message "data i has failed"
– HAL9000
Nov 21 at 15:08
logIfHasFailure logs a message "data i has failed"
– HAL9000
Nov 21 at 15:08
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You should probably use parametrized test instead:
TEST_P( something, something)
{
auto i{GetParam()};
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
}
INSTANTIATE_TEST_CASE_P(Default, something, testing::Values(0, 1, 2,3 ));
I like this answer
– HAL9000
Nov 21 at 15:09
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You should probably use parametrized test instead:
TEST_P( something, something)
{
auto i{GetParam()};
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
}
INSTANTIATE_TEST_CASE_P(Default, something, testing::Values(0, 1, 2,3 ));
I like this answer
– HAL9000
Nov 21 at 15:09
add a comment |
up vote
1
down vote
accepted
You should probably use parametrized test instead:
TEST_P( something, something)
{
auto i{GetParam()};
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
}
INSTANTIATE_TEST_CASE_P(Default, something, testing::Values(0, 1, 2,3 ));
I like this answer
– HAL9000
Nov 21 at 15:09
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You should probably use parametrized test instead:
TEST_P( something, something)
{
auto i{GetParam()};
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
}
INSTANTIATE_TEST_CASE_P(Default, something, testing::Values(0, 1, 2,3 ));
You should probably use parametrized test instead:
TEST_P( something, something)
{
auto i{GetParam()};
res = testMethodOverFile(i);
EXPECT_NEAR(res, results[i], 0.01);
}
INSTANTIATE_TEST_CASE_P(Default, something, testing::Values(0, 1, 2,3 ));
answered Nov 21 at 15:04
VTT
23.2k32345
23.2k32345
I like this answer
– HAL9000
Nov 21 at 15:09
add a comment |
I like this answer
– HAL9000
Nov 21 at 15:09
I like this answer
– HAL9000
Nov 21 at 15:09
I like this answer
– HAL9000
Nov 21 at 15:09
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414268%2fclearing-hasfailure-flag-in-gtest%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does
logIfHasFailure()
do? Does it print to the console or to some log file? Why is print fromEXPECT_NEAR
not sufficient?– Yksisarvinen
Nov 21 at 15:02
logIfHasFailure logs a message "data i has failed"
– HAL9000
Nov 21 at 15:08