Play 2.5:我可以通过Intelij IDEA进行测试,但不能使用./activator进行测试

时间:2016-11-10 17:29:31

标签: java junit sbt playframework-2.5

我运行假服务器进行批量功能测试,用进化填充数据库。这个想法很适合在IntelijIdea中测试,但我无法配置CI,因为激活器测试失败...

./activator -Dconfig.resource=env_test.conf testOnly com.api.test.FunctionalTestsSuite 
[info] Loading project definition from /Users/aieremenko/pr/api/project
[info] Set current project to api (in build file:/Users/aieremenko/pr/api/)
[info] Test run started
THE FIRST
[warn] application - hardcoded value: user is deprecated, use username instead
[info] application - Creating Pool for datasource 'default'
Starting server
before provideApplication
[error] Test com.api.test.FunctionalTestsSuite failed: play.api.Configuration$$anon$1: Configuration error[null], took 0.0 sec
[error]     at play.api.Configuration$.configError(Configuration.scala:154)
[error]     at play.api.Configuration.reportError(Configuration.scala:806)
[error]     at play.Configuration.reportError(Configuration.java:366)
[error]     at play.db.ebean.DefaultEbeanConfig$EbeanConfigParser.setServerConfigDataSource(DefaultEbeanConfig.java:94)
[error]     at play.db.ebean.DefaultEbeanConfig$EbeanConfigParser.parse(DefaultEbeanConfig.java:75)
[error]     at play.db.ebean.DefaultEbeanConfig$EbeanConfigParser.get(DefaultEbeanConfig.java:56)
[error]     at play.db.ebean.DefaultEbeanConfig$EbeanConfigParser.get(DefaultEbeanConfig.java:40)
[error]     at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
[error]     at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
[error]     at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
[error]     at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
[error]     at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
[error]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
[error]     at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
[error]     at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
[error]     at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
[error]     at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
[error]     at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
[error]     at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
[error]     at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
[error]     at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
[error]     at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
[error]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
[error]     at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
[error]     at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
[error]     at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
[error]     at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
[error]     at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
[error]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
[error]     at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
[error]     at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
[error]     at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
[error]     at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
[error]     at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
[error]     at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
[error]     at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
[error]     at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
[error]     at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
[error]     at com.google.inject.Guice.createInjector(Guice.java:96)
[error]     at com.google.inject.Guice.createInjector(Guice.java:84)
[error]     at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
[error]     at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
[error]     at play.api.test.FakeApplication.<init>(Fakes.scala:209)
[error]     at play.test.FakeApplication.<init>(FakeApplication.java:51)
[error]     at play.test.Helpers.fakeApplication(Helpers.java:124)
[error]     at com.dimanex.api.test.FunctionalTestsSuite$1.provideApplication(FunctionalTestsSuite.java:105)
[error]     at com.dimanex.api.test.FunctionalTestsSuite$1.startServer(FunctionalTestsSuite.java:54)
[error]     at com.dimanex.api.test.FunctionalTestsSuite$1.before(FunctionalTestsSuite.java:38)
[error]     ...
[error] Caused by: java.lang.NullPointerException
[error]     at play.db.ebean.DefaultEbeanConfig$EbeanConfigParser.setServerConfigDataSource(DefaultEbeanConfig.java:92)
[error]     ... 64 more
[info] Test run finished: 1 failed, 0 ignored, 0 total, 41.043s

我已经为dev,prod和测试模式配置了文件。测试使用自己的数据库错过了损害生产服务器的可能性(我不使用内存数据库)....

1 个答案:

答案 0 :(得分:0)

好。激活器只是忽略测试插件的-Dconfig.resource = env_test.conf。当我使用application.conf进行测试时(默认配置文件)而不是它的工作原理。对于应用程序运行,它可以工作:

./activator -Dconfig.resource=env_dev.conf run

但是它的IntelijIdea运行测试很好,使用了defiled -Dconfig.resource = env_test.conf。这很有趣:)