playframework/play-scala-angular-seed

[Question] How to run backend tests only?

hossameldeen opened this issue · 5 comments

Use-case: TDD on the backend, using sbt ~test. The frontend tests add too much noise.

A workaround: I know I can do it by commenting this line test := ((test in Test) dependsOn ui-test).value. But is there a command for it without changing the source code?

A generalization: How to run any command (e.g., run) for the backend only?

Thanks in advance! :-) (and in all cases, if there's no solution for that at the moment :) )

@hossameldeen, Please replace

@yohangz Sorry, I don't understand. Replace what?

@hossameldeen, sorry about that. I mistakenly hit the comment button. :) I will get back to you ASAP.

@hossameldeen, please replace

// Execute frontend test task prior to play test execution.
test := ((test in Test) dependsOn `ui-test`).value

with

lazy val testAll = taskKey[Unit]("Run backend and frontend tests.")

// Execute frontend test task prior to play test execution.
testAll := ((test in Test) dependsOn `ui-test`).value

then you can use test to run backend tests while testAll to run both UI and backend

Perfect, thank you @yohangz (Y)

Another note for future readers interested in TDD with this seed: You might find ~testQuick useful as well. And note that it happens to be for backend only, there's no version of it for the frontend (I wasn't interested in TDDing the frontend anyway).

One more note for future readers: If you want to use TDD with IntelliJ test runners, you might find the Alt+Shift+F10 shortcut useful. Yup, not really related to the issue but in case someone finds themselves in the exact same position as me :-)

Anyway, thanks again and wish you luck! :-)