Skip to content

Comments

Expect_called fn addition#20

Open
danilito19 wants to merge 8 commits intorobertzk:masterfrom
danilito19:exp-called
Open

Expect_called fn addition#20
danilito19 wants to merge 8 commits intorobertzk:masterfrom
danilito19:exp-called

Conversation

@danilito19
Copy link
Contributor

  • This PR adds expect_call helper function, tests, up version, documentation, etc.

May need some suggestions for improvements, especially for the last test (commented out) that doesn't pass when wrapped in either test_that or describe.

I"ve also added .DS_Store to .gitignore.

@danilito19
Copy link
Contributor Author

I ran test("~/dev/testthatsomemore") before pushing the branch and tests passed. What's the best way to figure out why my tests wouldn't pass travis?

expect_true(expect_called(sum, f(), "base"))
})

# neither test_that nor describe wrappers work here?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danilito19 What was the problem?

@robertzk
Copy link
Owner

@danilito19 Opening up the travis build shows the failures

1. Error: it finds called function (@test-expect_called.R#6) -------------------
could not find function "duplicate"
1: expect_true(expect_called(base::sum, f())) at testthat/test-expect_called.R:6
2: expect(identical(as.vector(object), TRUE), sprintf("%s isn't true.", lab), info = info)
3: as.expectation(exp, ..., srcref = srcref)
4: identical(as.vector(object), TRUE)
5: as.vector(object)
6: expect_called(base::sum, f())
2. Error: it detects function was not called (@test-expect_called.R#11) --------
could not find function "duplicate"
1: expect_true(expect_called(base::sum, f(), was_called = FALSE)) at testthat/test-expect_called.R:11
2: expect(identical(as.vector(object), TRUE), sprintf("%s isn't true.", lab), info = info)
3: as.expectation(exp, ..., srcref = srcref)
4: identical(as.vector(object), TRUE)
5: as.vector(object)
6: expect_called(base::sum, f(), was_called = FALSE)
3. Error: Package setting works (@test-expect_called.R#16) ---------------------
could not find function "duplicate"
1: expect_true(expect_called(sum, f(), "base")) at testthat/test-expect_called.R:16
2: expect(identical(as.vector(object), TRUE), sprintf("%s isn't true.", lab), info = info)
3: as.expectation(exp, ..., srcref = srcref)
4: identical(as.vector(object), TRUE)
5: as.vector(object)
6: expect_called(sum, f(), "base")

You have to define the duplicate function (might require changes to src/ ).

@danilito19
Copy link
Contributor Author

@robertzk could you point me to where you got that stack? All I see is where the tests failed. Where in travis could I find that (for next time)?

@robertzk
Copy link
Owner

@danilito19 I think it's hidden by default unfortunately - you have to scroll to the bottom and click after_failure

screen shot 2016-07-14 at 2 16 58 pm

@robertzk
Copy link
Owner

@danilito19 Don't forget to devtools::document() or the NAMESPACE file won't be updated. That should fix tests.

@danilito19
Copy link
Contributor Author

@peterhurford another pretend_now_is test failure

Error: Test failed: 'it can pretend it's 5 seconds ago'
Not expected: Sys.time() not equal to five_s_ago
Mean absolute difference: 0.001155853.

I'll look into it

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.5%) to 98.485% when pulling b1cefc1 on danilito19:exp-called into e68b47b on robertzk:master.

@peterhurford
Copy link
Contributor

This still happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants