所以我已经查看了其他人的问题,但是他们看不到我所看到的情况,所以我认为我会发布它,看看是否有其他人有这个问题并且有一个建议的解决方案
我在2.3.5中运行grails应用程序并且使用黄瓜1.2.0
我在功能文件夹中设置了一个非常基本的功能文件,内容如下: -
Feature:
As a user
If I enter the incorrect password I need a warning message
So I know i did something wrong
Scenario:
Given I enter the wrong login credentials
When I click sign in
Then Display a login error
现在我知道这应该不会起作用,但是我一步一步看到这个过程是我对黄瓜和老鼠的新手。
如果我使用命令
,应用程序运行正常 grails run-app -Dgrails.server.port.http=8090
如果我尝试通过
运行黄瓜测试 grails test-app :cucumber
(有或没有上面的端口规范)我得到以下爆炸......
Configuring Shiro ...
Shiro Configured
| Error 2017-03-15 08:28:35,222 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: null
Message: null
Line | Method
->> 2076 | contains in java.lang.String
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 207 | canAutoMigrate in grails.plugin.databasemigration.MigrationUtils
| 43 | autoRun . . . in grails.plugin.databasemigration.MigrationRunner
| 87 | doCall in DatabaseMigrationGrailsPlugin$_closure2
| 262 | run . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
| Error 2017-03-15 08:28:35,247 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing Grails: null
Message: null
Line | Method
->> 2076 | contains in java.lang.String
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 207 | canAutoMigrate in grails.plugin.databasemigration.MigrationUtils
| 43 | autoRun . . . in grails.plugin.databasemigration.MigrationRunner
| 87 | doCall in DatabaseMigrationGrailsPlugin$_closure2
| 262 | run . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
| Error 2017-03-15 08:28:35,251 [localhost-startStop-1] ERROR [localhost].[/test] - Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
Message: Error executing bootstraps; nested exception is java.lang.NullPointerException
Line | Method
->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by NullPointerException: null
->> 2076 | contains in java.lang.String
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 207 | canAutoMigrate in grails.plugin.databasemigration.MigrationUtils
| 43 | autoRun . in grails.plugin.databasemigration.MigrationRunner
| 87 | doCall in DatabaseMigrationGrailsPlugin$_closure2
| 262 | run . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
| Error 2017-03-15 08:28:35,271 [localhost-startStop-1] ERROR core.StandardContext - Error listenerStart
| Error 2017-03-15 08:28:35,280 [localhost-startStop-1] ERROR core.StandardContext - Context [/myProject] startup failed due to previous errors
| Server running. Browse to http://localhost:8080/myProject
| Server stopped
| Error Fatal error running tests: No WebApplicationContext found: no ContextLoaderListener registered? (Use --stacktrace to see the full trace)
| Tests FAILED - view reports in /Users/me/Projects/myProject/target/test-reports
| Error Error executing script TestApp: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? (Use --stacktrace to see the full trace)
我知道这意味着什么,谷歌/黄瓜上下文中的任何一个谷歌似乎并没有真正带回任何意义,任何建议或问题欢迎!
这是我的bootstrap.groovy文件的内容,如果这让事情变得更清楚,intellij在这里没有注册任何东西,只是因为没有使用一些变量...
import org.apache.shiro.crypto.hash.Sha256Hash
import uk.co.test.*
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
class BootStrap {
def queueService
def init = { servletContext ->
def adminRole = new ShiroRole(name: "admin")
adminRole.addToPermissions("admin:*:*")
adminRole.save()
def userRole = new ShiroRole(name: "user")
userRole.addToPermissions("application:*:*")
userRole.addToPermissions("assertion:*:*")
userRole.addToPermissions("auth:*:*")
userRole.addToPermissions("displayResult:*:*")
userRole.addToPermissions("event:*:*")
userRole.addToPermissions("executor:*:*")
userRole.addToPermissions("folderNode:*:*")
userRole.addToPermissions("form:*:*")
userRole.addToPermissions("interaction:*:*")
userRole.addToPermissions("manualTest:*:*")
userRole.addToPermissions("object:*:*")
userRole.addToPermissions("objectType:*:*")
userRole.addToPermissions("page:*:*")
userRole.addToPermissions("project:*:*")
userRole.addToPermissions("queue:*:*")
userRole.addToPermissions("release:*:*")
userRole.addToPermissions("result:*:*")
userRole.addToPermissions("test:*:*")
userRole.addToPermissions("testSet:*:*")
userRole.addToPermissions("user:*:*")
userRole.save()
def adminUser = new ShiroUser(username: "admin", passwordHash: new Sha256Hash("test").toHex())
adminUser.addToRoles(adminRole)
adminUser.addToRoles(userRole)
adminUser.save()
def nonAdminUser = new ShiroUser(username: "user", passwordHash: new Sha256Hash("test").toHex())
nonAdminUser.addToRoles(userRole)
nonAdminUser.save()
if (Interaction.list().size() == 0) {
def interaction = new Interaction('click')
interaction.save(failOnError: true)
interaction = new Interaction(name: 'check text', alias: 'checkText')
interaction.save(failOnError: true)
interaction = new Interaction(name: 'get attribute', alias: 'getAttribute')
interaction.save(failOnError: true)
interaction = new Interaction(name: 'enter text', alias: 'type')
interaction.save(failOnError: true)
interaction = new Interaction('select radio button')
interaction.save(failOnError: true)
interaction = new Interaction('select')
interaction.save(failOnError: true)
interaction = new Interaction('hover')
interaction.save(failOnError: true)
}
if (ObjectType.findAll().size() == 0) {
def firstType = new ObjectType(type: "button", typeSysCode: "BUTTON")
firstType.save()
def secondType = new ObjectType(type: "link", typeSysCode: "LINK")
secondType.save()
def thirdType = new ObjectType(type: "label", typeSysCode: "LABEL")
thirdType.save()
def fourthType = new ObjectType(type: "textbox", typeSysCode: "TEXTBOX")
fourthType.save()
}
if (Queue.list().size() == 0) {
def manualQueue = new Queue(name: "manual",
allowedTestTypes: [TestTypes.MANUAL.getValue()]
)
manualQueue.save(failOnError: true)
}
def sd = Executors.newSingleThreadScheduledExecutor()
sd.scheduleAtFixedRate(new QueueRunnable(), 10, 5, TimeUnit.SECONDS)
environments {
development {
def firstRelease
def secondRelease
if (Release.findAll().size() == 0) {
def firstProject
def secondProject
if (Project.findAll().size() == 0) {
firstProject = new Project(name: "d2c application")
firstProject.save(failOnError: true)
secondProject = new Project(name: "b2b application")
secondProject.save(failOnError: true)
} else {
firstProject = Project.findByName("d2c application")
secondProject = Project.findByName("b2b application")
}
if (Release.findAll().size() == 0) {
firstRelease = new Release(name: "d2c 1", project: firstProject)
firstRelease.save()
secondRelease = new Release(name: "d2c 2", parentRelease: Release.findByNameAndProject('d2c 1', firstProject), project: firstProject)
secondRelease.save()
def thirdRelease = new Release(name: "b2b 1", project: secondProject)
thirdRelease.save()
def fourthRelease = new Release(name: "b2b 2", parentRelease: Release.findByNameAndProject('b2b 1', secondProject), project: secondProject)
fourthRelease.save()
}
} else {
firstRelease = Release.get(1)
secondRelease = Release.get(2)
}
if (Object.findAll().size() == 0 && Page.findAll().size() == 0) {
def firstObject = new Object(name: "BBC welcome text",
idType: "css",
locatorValue: "h2.hp-banner__text",
type: ObjectType.get(2),
release: firstRelease,
objectVersion: 1,
objectNumber: 1,
interaction: Interaction.findByName('check text')
)
firstObject.save(failOnError: true)
def secondObject = new Object(name: "BBC news link",
idType: "css",
locatorValue: "li.orb-nav-news a",
type: ObjectType.get(1),
release: firstRelease,
objectVersion: 1,
objectNumber: 2,
interaction: Interaction.findByName('click')
)
secondObject.save(failOnError: true)
def thirdObject = new Object(name: "BBC news business link",
idType: "id",
locatorValue: "linky",
type: ObjectType.get(2),
release: firstRelease,
objectVersion: 1,
objectNumber: 3,
interaction: Interaction.findByName('click')
)
thirdObject.save(failOnError: true)
def firstPage = new Page(name: "BBC home",
pageNumber: 1,
pageVersion: 1,
release: firstRelease
)
firstPage.save(failOnError: true)
def secondPage = new Page(name: "BBC news",
pageNumber: 2,
pageVersion: 1,
release: firstRelease
)
secondPage.save(failOnError: true)
def firstPageObject = new PageObject(object: firstObject,
objectNumber: firstObject.objectNumber,
page: firstPage,
behaviour: "interact",
value: "Welcome to the BBC"
)
firstPageObject.save(failOnError: true)
def secondPageObject = new PageObject(object: secondObject,
objectNumber: secondObject.objectNumber,
page: firstPage,
behaviour: "interact"
)
secondPageObject.save(failOnError: true)
def thirdPageObject = new PageObject(object: thirdObject,
objectNumber: thirdObject.objectNumber,
page: secondPage,
behaviour: "interact"
)
thirdPageObject.save(failOnError: true)
firstPage.objects = [firstPageObject, secondPageObject]
firstPage.save(failOnError: true)
secondPage.objects = [thirdPageObject]
secondPage.save(failOnError: true)
}
}
}
}
def destroy = {
}
}