jamovi / jmv

jamovi for R
https://www.jamovi.org
55 stars 27 forks source link

Duplicate code in test in testttestis.R #376

Closed karchjd closed 1 month ago

karchjd commented 1 year ago

The test 'Error is thrown if grouping var has more than 2 levels' is twice in the file.

jonathon-love commented 1 year ago

we are getting all passes on our unit tests here ...

Screenshot 2023-02-22 at 10 03 11
karchjd commented 1 year ago

It seems like I should have been more specific. Have a look at lines 90 to 116:

testthat::test_that('Error is thrown if grouping var has more than 2 levels', {
    df <- data.frame(
        dep = c(1, 7, 4),
        group = c("a", "b", "c"),
        stringsAsFactors = TRUE
    )

    testthat::expect_error(
        jmv::ttestIS(df, vars = "dep", group = "group"),
        "Grouping variable 'group' must have exactly 2 levels",
        fixed=TRUE
    )
})

testthat::test_that('Error is thrown if grouping var has more than 2 levels', {
    df <- data.frame(
        dep = c(1, 7, 4),
        group = c("a", "b", "c"),
        stringsAsFactors = TRUE
    )

    testthat::expect_error(
        jmv::ttestIS(df, vars = "dep", group = "group"),
        "Grouping variable 'group' must have exactly 2 levels",
        fixed=TRUE
    )
})

The unit tests contain exactly the same test twice. Not really a problem but just wanted to let you know,

raviselker commented 1 month ago

Well, that took us a lot longer to fix than necessary 😛. Thank you for reporting this though!