`testthat` test does run when running in session, but results in error in testTest for exact string in testthattestthat in R: sourcing in tested filestestthat pattern for long-running testsR testthat not reporting failures or errorsobject no found error in testthat testsRun a code snippet before and after tests with testthatr - data.table and testthat packageR: Using all.equal with more than two objectsHow to test standalone R scripts which are part of a package using testthatHow to run a package's testthat tests

Uncovering the Accelerated Dragon opening

Can the UK veto its own extension request?

How can I discourage sharing internal API keys within a company?

My research paper filed as a patent in China by my Chinese supervisor without me as inventor

Does an oscilloscope subtract voltages as phasors?

Does a gnoll speak both Gnoll and Abyssal, or is Gnoll a dialect of Abyssal?

ArcPy: define fields to keep, delete all other fields in a feature class

Do all humans have an identical nucleotide sequence for certain proteins, e.g haemoglobin?

Double it your way

What are uses of the byte after BRK instruction on 6502?

Are there any non-WEB re-implementation of TeX Core in recent years?

Mean π: Archimedes vs. Gauss - π computation through generalized means

Are Democrats more likely to believe Astrology is a science?

Random point on a sphere

What is my breathable atmosphere composed of?

Why is the T-1000 humanoid?

Can I conceal an antihero's insanity - and should I?

Can I toggle Do Not Disturb on/off on my Mac as easily as I can on my iPhone?

A shy person in a queue

Gravity on an Orbital Ring

Evidence that matrix multiplication cannot be done in O(n^2 poly(log(n))) time

Selecting 2 column in an Inner join

Shouldn't the minimum Succah size be 6x7 Tfachim?

Is low emotional intelligence associated with right-wing and prejudiced attitudes?



`testthat` test does run when running in session, but results in error in test


Test for exact string in testthattestthat in R: sourcing in tested filestestthat pattern for long-running testsR testthat not reporting failures or errorsobject no found error in testthat testsRun a code snippet before and after tests with testthatr - data.table and testthat packageR: Using all.equal with more than two objectsHow to test standalone R scripts which are part of a package using testthatHow to run a package's testthat tests






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a problem with testthat test below. specifically the first test.



It runs when I execute it directly (the whole test_that() block), but it fails when using testthat::test_file() on that file (and obviously when the tests are all executed as well). From



context("validate()")

x <- emeScheme_raw
print(validate( x = x, errorIfStructFalse = TRUE))

test_that(
"validata_raw() returns correct value when correct",

expect_known_value(
object = validate( x = x, errorIfStructFalse = TRUE),
file = "validate.CORRECT.rda"
)

)

names(x)[1] <- "experiment"

test_that(
"validata_raw() fails",

expect_known_value(
object = validate( x = x, errorIfStructFalse = FALSE),
file = "validate.DIFFERENCES.rda"
)

)

test_that(
"validata_raw() fails",

expect_error(
object = validate( x = x, errorIfStructFalse = TRUE),
regexp = ("Structure of the object to be evaluated is wrong. See the info above for details.")
)

)


results in



 testthat::test_file("./tests/testthat/test-validate.R")
✔ | OK F W S | Context
⠙ | 1 1 | validate()Names: 1 string mismatch
✖ | 2 1 | validate() [0.8 s]
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
test-validate.R:10: error: validata_raw() returns correct value when correct
missing value where TRUE/FALSE needed
1: expect_known_value(object = validate(x = x, errorIfStructFalse = TRUE), file = "validate.CORRECT.rda") at ./tests/testthat/test-validate.R:10
2: compare(act$val, ref_val, ...)
3: compare.default(act$val, ref_val, ...)
4: all.equal(x, y, ...)
5: all.equal.list(x, y, ...)
6: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
7: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
8: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
9: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
10: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
11: all.equal.default(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
12: all.equal.list(target, current, ...)
13: paste0("Component ", if (use.names && nt[i] == nc[i]) dQuote(nt[i]) else i, ": ", mi)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 0.8 s

OK: 2
Failed: 1
Warnings: 0
Skipped: 0


If I read the error correctly, the error occurs in the expect_known_value() function and not in the validate() function which makes sense, as that function works (if I put it after the x <- assignment, it runs successfully and returns the results.



I know this is difficult without a reproducible example, but any ideas what is going on?










share|improve this question


























  • It is working now with the same code. I think, that the file validate.CORRECT.rda was corrupted, because I could not read it in into Rstudio. So I deleted it, and it worked.

    – Rainer
    Mar 28 at 9:51











  • Since this is an unreproducible problem, similar to a typo, I think it should probably be deleted. Would you be happy to do that?

    – r.bot
    Mar 28 at 10:21

















2















I have a problem with testthat test below. specifically the first test.



It runs when I execute it directly (the whole test_that() block), but it fails when using testthat::test_file() on that file (and obviously when the tests are all executed as well). From



context("validate()")

x <- emeScheme_raw
print(validate( x = x, errorIfStructFalse = TRUE))

test_that(
"validata_raw() returns correct value when correct",

expect_known_value(
object = validate( x = x, errorIfStructFalse = TRUE),
file = "validate.CORRECT.rda"
)

)

names(x)[1] <- "experiment"

test_that(
"validata_raw() fails",

expect_known_value(
object = validate( x = x, errorIfStructFalse = FALSE),
file = "validate.DIFFERENCES.rda"
)

)

test_that(
"validata_raw() fails",

expect_error(
object = validate( x = x, errorIfStructFalse = TRUE),
regexp = ("Structure of the object to be evaluated is wrong. See the info above for details.")
)

)


results in



 testthat::test_file("./tests/testthat/test-validate.R")
✔ | OK F W S | Context
⠙ | 1 1 | validate()Names: 1 string mismatch
✖ | 2 1 | validate() [0.8 s]
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
test-validate.R:10: error: validata_raw() returns correct value when correct
missing value where TRUE/FALSE needed
1: expect_known_value(object = validate(x = x, errorIfStructFalse = TRUE), file = "validate.CORRECT.rda") at ./tests/testthat/test-validate.R:10
2: compare(act$val, ref_val, ...)
3: compare.default(act$val, ref_val, ...)
4: all.equal(x, y, ...)
5: all.equal.list(x, y, ...)
6: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
7: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
8: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
9: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
10: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
11: all.equal.default(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
12: all.equal.list(target, current, ...)
13: paste0("Component ", if (use.names && nt[i] == nc[i]) dQuote(nt[i]) else i, ": ", mi)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 0.8 s

OK: 2
Failed: 1
Warnings: 0
Skipped: 0


If I read the error correctly, the error occurs in the expect_known_value() function and not in the validate() function which makes sense, as that function works (if I put it after the x <- assignment, it runs successfully and returns the results.



I know this is difficult without a reproducible example, but any ideas what is going on?










share|improve this question


























  • It is working now with the same code. I think, that the file validate.CORRECT.rda was corrupted, because I could not read it in into Rstudio. So I deleted it, and it worked.

    – Rainer
    Mar 28 at 9:51











  • Since this is an unreproducible problem, similar to a typo, I think it should probably be deleted. Would you be happy to do that?

    – r.bot
    Mar 28 at 10:21













2












2








2








I have a problem with testthat test below. specifically the first test.



It runs when I execute it directly (the whole test_that() block), but it fails when using testthat::test_file() on that file (and obviously when the tests are all executed as well). From



context("validate()")

x <- emeScheme_raw
print(validate( x = x, errorIfStructFalse = TRUE))

test_that(
"validata_raw() returns correct value when correct",

expect_known_value(
object = validate( x = x, errorIfStructFalse = TRUE),
file = "validate.CORRECT.rda"
)

)

names(x)[1] <- "experiment"

test_that(
"validata_raw() fails",

expect_known_value(
object = validate( x = x, errorIfStructFalse = FALSE),
file = "validate.DIFFERENCES.rda"
)

)

test_that(
"validata_raw() fails",

expect_error(
object = validate( x = x, errorIfStructFalse = TRUE),
regexp = ("Structure of the object to be evaluated is wrong. See the info above for details.")
)

)


results in



 testthat::test_file("./tests/testthat/test-validate.R")
✔ | OK F W S | Context
⠙ | 1 1 | validate()Names: 1 string mismatch
✖ | 2 1 | validate() [0.8 s]
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
test-validate.R:10: error: validata_raw() returns correct value when correct
missing value where TRUE/FALSE needed
1: expect_known_value(object = validate(x = x, errorIfStructFalse = TRUE), file = "validate.CORRECT.rda") at ./tests/testthat/test-validate.R:10
2: compare(act$val, ref_val, ...)
3: compare.default(act$val, ref_val, ...)
4: all.equal(x, y, ...)
5: all.equal.list(x, y, ...)
6: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
7: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
8: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
9: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
10: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
11: all.equal.default(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
12: all.equal.list(target, current, ...)
13: paste0("Component ", if (use.names && nt[i] == nc[i]) dQuote(nt[i]) else i, ": ", mi)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 0.8 s

OK: 2
Failed: 1
Warnings: 0
Skipped: 0


If I read the error correctly, the error occurs in the expect_known_value() function and not in the validate() function which makes sense, as that function works (if I put it after the x <- assignment, it runs successfully and returns the results.



I know this is difficult without a reproducible example, but any ideas what is going on?










share|improve this question
















I have a problem with testthat test below. specifically the first test.



It runs when I execute it directly (the whole test_that() block), but it fails when using testthat::test_file() on that file (and obviously when the tests are all executed as well). From



context("validate()")

x <- emeScheme_raw
print(validate( x = x, errorIfStructFalse = TRUE))

test_that(
"validata_raw() returns correct value when correct",

expect_known_value(
object = validate( x = x, errorIfStructFalse = TRUE),
file = "validate.CORRECT.rda"
)

)

names(x)[1] <- "experiment"

test_that(
"validata_raw() fails",

expect_known_value(
object = validate( x = x, errorIfStructFalse = FALSE),
file = "validate.DIFFERENCES.rda"
)

)

test_that(
"validata_raw() fails",

expect_error(
object = validate( x = x, errorIfStructFalse = TRUE),
regexp = ("Structure of the object to be evaluated is wrong. See the info above for details.")
)

)


results in



 testthat::test_file("./tests/testthat/test-validate.R")
✔ | OK F W S | Context
⠙ | 1 1 | validate()Names: 1 string mismatch
✖ | 2 1 | validate() [0.8 s]
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
test-validate.R:10: error: validata_raw() returns correct value when correct
missing value where TRUE/FALSE needed
1: expect_known_value(object = validate(x = x, errorIfStructFalse = TRUE), file = "validate.CORRECT.rda") at ./tests/testthat/test-validate.R:10
2: compare(act$val, ref_val, ...)
3: compare.default(act$val, ref_val, ...)
4: all.equal(x, y, ...)
5: all.equal.list(x, y, ...)
6: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
7: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
8: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
9: all.equal.list(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
10: all.equal(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
11: all.equal.default(target[[i]], current[[i]], check.attributes = check.attributes, use.names = use.names, ...)
12: all.equal.list(target, current, ...)
13: paste0("Component ", if (use.names && nt[i] == nc[i]) dQuote(nt[i]) else i, ": ", mi)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 0.8 s

OK: 2
Failed: 1
Warnings: 0
Skipped: 0


If I read the error correctly, the error occurs in the expect_known_value() function and not in the validate() function which makes sense, as that function works (if I put it after the x <- assignment, it runs successfully and returns the results.



I know this is difficult without a reproducible example, but any ideas what is going on?







r testthat






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 9:26









phiver

14.9k10 gold badges30 silver badges37 bronze badges




14.9k10 gold badges30 silver badges37 bronze badges










asked Mar 28 at 9:25









RainerRainer

5,9871 gold badge13 silver badges19 bronze badges




5,9871 gold badge13 silver badges19 bronze badges















  • It is working now with the same code. I think, that the file validate.CORRECT.rda was corrupted, because I could not read it in into Rstudio. So I deleted it, and it worked.

    – Rainer
    Mar 28 at 9:51











  • Since this is an unreproducible problem, similar to a typo, I think it should probably be deleted. Would you be happy to do that?

    – r.bot
    Mar 28 at 10:21

















  • It is working now with the same code. I think, that the file validate.CORRECT.rda was corrupted, because I could not read it in into Rstudio. So I deleted it, and it worked.

    – Rainer
    Mar 28 at 9:51











  • Since this is an unreproducible problem, similar to a typo, I think it should probably be deleted. Would you be happy to do that?

    – r.bot
    Mar 28 at 10:21
















It is working now with the same code. I think, that the file validate.CORRECT.rda was corrupted, because I could not read it in into Rstudio. So I deleted it, and it worked.

– Rainer
Mar 28 at 9:51





It is working now with the same code. I think, that the file validate.CORRECT.rda was corrupted, because I could not read it in into Rstudio. So I deleted it, and it worked.

– Rainer
Mar 28 at 9:51













Since this is an unreproducible problem, similar to a typo, I think it should probably be deleted. Would you be happy to do that?

– r.bot
Mar 28 at 10:21





Since this is an unreproducible problem, similar to a typo, I think it should probably be deleted. Would you be happy to do that?

– r.bot
Mar 28 at 10:21












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55394082%2ftestthat-test-does-run-when-running-in-session-but-results-in-error-in-test%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55394082%2ftestthat-test-does-run-when-running-in-session-but-results-in-error-in-test%23new-answer', 'question_page');

);

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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해