swift - tests not working in vapor app -
i've been unable tests working in vapor app. seems linker doesn't find of app classes being tested. narrow problem down, i've tried creating simplest test possible using default app template. steps shown below. if can either tell me i'm doing wrong, or can replicate issue, i'd grateful.
- create new project.
$ vapor new foo cloning template [done] $ cd foo $ mkdir -p tests/modeltests
- add dummy test references class in default project.
$ cat > tests/modeltests/posttests.swift import xctest @testable import app class posttests: xctestcase { func testpost() { print(post.self) xctassertequal("a", "a") } } ^d
- build project.
$ vapor build no packages folder, fetch may take while... fetching dependencies [done] building project [done]
- run tests.
$ vapor test testing [failed] log: swift-test: error: no tests found execute, create module in `tests' directory
- oops, seems need remove "tests" exclude: section of package.swift.
$ vi package.swift ... remove tests exclude: ....
- try again.
$ vapor test testing [failed] log: <unknown>:0: error: build had 1 command failures swift-test: error: exit(1): /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/swift-build-tool -f /users/mark/tmp/foo/.build/debug.yaml test
- try directly executing command line shown above.
$ /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/swift-build-tool -f /users/mark/tmp/foo/.build/debug.yaml test linking ./.build/debug/foopackagetests.xctest/contents/macos/foopackagetests undefined symbols architecture x86_64: "__tmac3app4post", referenced from: __tfc10modeltests9posttests8testpostft_t_ in posttests.swift.o __tmamc3app4post in posttests.swift.o ld: symbol(s) not found architecture x86_64 <unknown>:0: error: link command failed exit code 1 (use -v see invocation) <unknown>:0: error: build had 1 command failures
this behavior see in own project well: linker doesn't find classes app referenced in test.
solved, see comment below.
put in comments, people can see answer, i'll mark here too:
swiftpm enforces naming conventions on tests, proper naming <#yourtarget#>tests
.
in case, rename test module apptests
, should trick!
Comments
Post a Comment