2016-11-02 4 views
0

私はtestthatにJUnitレポーターを追加しようとしています。私はそれを行うことができますのパッケージ(https://github.com/hadley/testthat/pull/481)私は別のパッケージ(https://github.com/lbartnik/testthatJUnit)のときに同じテストのセットを渡すことはできません。testthatにレポーターを追加するには?

私の主な問題は、私がJUnitレポーターコードを別のパッケージに引っ張っても、記者のために設計され、testthatにあるテストが合格しないということです。私は、これらのテストに、記者をテストするための「シーンを設定する」ものがあると推測していますが、この「何か」を特定することはできません。

ご迷惑をおかけして申し訳ございません。

詳細はこちら

> library(devtools) 
> test("testthatJUnit") 
Loading testthatJUnit 
Testing testthatJUnit 
JUnitReporter: 

DONE ========================================================================== 
> test("testthat")  
Loading testthat 
unloadNamespace("testthat") not successful, probably because another loaded package depends on it.Forcing unload. If you encounter problems, please restart R. 
Testing testthat 
Bare expectations: 
Colours: .. 
compare.character: ................. 
compare.numeric: ..................... 
compare.time: ....... 
# ... lines cut ... 

DONE =========================================================================== 
> test("testthatJUnit") 
Loading testthatJUnit 
Testing testthatJUnit 
JUnitReporter: ............. 

最初test("testthatJUnit")が沈黙している理由を私は見るためにテストを変更した場合、私はこれを参照してください。

> test("testthatJUnit") 
Loading testthatJUnit 
Testing testthatJUnit 
JUnitReporter: Bare: .1 
Failed ------------------------------------------------------------------------- 
1. Error: Junit reporter regression (@test-reporter-junit.R#13) ---------------- 
attempt to apply non-function 
1: test_dir("test_dir") at /mnt/storage-a/lukaszb/src/third-party/testthatJUnit/tests/testthat/test-reporter-junit.R:13 
2: test_files(paths, reporter = reporter, env = env, ...) 
3: with_reporter(reporter = current_reporter, results <- lapply(paths, test_file, env = env, 
     reporter = current_reporter, start_end_reporter = FALSE, load_helpers = FALSE)) 
4: force(code) 
5: lapply(paths, test_file, env = env, reporter = current_reporter, start_end_reporter = FALSE, 
     load_helpers = FALSE) 
6: FUN(X[[i]], ...) 
7: with_reporter(reporter = reporter, start_end_reporter = start_end_reporter, { 
     lister$start_file(basename(path)) 
     source_file(path, new.env(parent = env), chdir = TRUE) 
     end_context() 
    }) 
8: force(code) 
9: source_file(path, new.env(parent = env), chdir = TRUE) 
10: eval(exprs, env) 
11: eval(expr, envir, enclos) 
12: expect_that(1, equals(1)) at test_dir/test-bare-expectations.R:3 
13: condition(object) 
14: expect_equal(x, expected, ..., expected.label = label) 
15: expect(comp$equal, sprintf("%s not equal to %s.\n%s", lab_act, lab_exp, comp$message), 
     info = info) 
16: withRestarts(if (expectation_broken(exp)) { 
     stop(exp) 
    } else { 
     signalCondition(exp) 
    }, continue_test = function(e) NULL) 
17: withOneRestart(expr, restarts[[1L]]) 
18: doWithOneRestart(return(expr), restart) 
19: signalCondition(exp) 
20: (function (e) 
    { 
     register_expectation(e, frame + 11, sys.nframe() - 6) 
     invokeRestart("continue_test") 
    })(structure(list(message = "1 not equal to 1.\nEqual\n", srcref = NULL), .Names = c("message", 
    "srcref"), class = c("expectation_success", "expectation", "condition"))) 
21: register_expectation(e, frame + 11, sys.nframe() - 6) 
22: get_reporter()$add_result(context = get_reporter()$.context, test = test, result = e) 
23: o_apply(self$reporters, "add_result", context = context, test = test, result = result) 
24: lapply(objects, function(x) x[[method]](...)) 
25: FUN(X[[i]], ...) 
26: x[[method]](...) 

をしかし、私はtest("testthat")を実行した場合、再びtest("testthatJUnit")すべてが正常に戻ってくる:

> test("testthatJUnit") 
Loading testthatJUnit 
Testing testthatJUnit 
JUnitReporter: Bare: .. 
Basic: ....... 
empty: 1 
error: 2.3456. 
failures: 7.8.. 
helper: . 
skip: S 

私は、testthatのテストでは、記者をテストするためのシーンを設定するものがあると推測していますが、これまでのところはありませんそれを特定することができました。どんな助け?

答えて

関連する問題