2016-11-02 3 views
0

나는 testthat에 JUnit 리포터를 추가하려고합니다. 내가 (https://github.com/hadley/testthat/pull/481) 안에 그것을 할 수있는 동안 나는 별도의 패키지 (https://github.com/lbartnik/testthatJUnit)에서 같은 세트의 테스트를 통과하게 할 수 없다.시험에 기자를 추가하는 방법은 무엇입니까?

내 주된 문제는 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의 테스트에 뭔가있는 것 같지만 지금까지는 테스트하지 않았습니다. 그것을 확인할 수있었습니다. 어떤 도움이 필요합니까?

답변