QAF | Scenario needs to skip if dependent scenario gets fail - qaf

Team,
Problem statement: Scenario2 should skip if dependent scenario1 gets fail. Need some support to fix this issue.
Reference: I took reference from below link Skip Dependent scenario issue
Issue: End up with error after added #dependsOnMethods:['scenario1']
**Caused by: org.testng.TestNGException:
Method "scenarios.suite1.feature.scenario2()[pri:2, instance:com.qmetry.qaf.automation.step.client.Scenario#2]" depends on nonexistent method "scenario1"**
Example Feature file:
```Feature: Google Search
#priority:1`enter code here`
Scenario: Scenario1
Given COMMENT: "SC1"
And Call negative step
#priority:2 #dependsOnMethods:['scenario1']
Scenario: Scenario2
Given COMMENT: "SC2" ```
**I used same listener from the above link**
public class DependecyListener implements ITestListener {
#Override
public void onTestStart(ITestResult result) {
ITestNGMethod method = result.getMethod();
String[] methodsDependedUpon = method.getMethodsDependedUpon();
if (method.isTest() && null != methodsDependedUpon && methodsDependedUpon.length > 0) {
List<String> methodsDependedUponLst = Arrays.asList(methodsDependedUpon);
IResultMap failedTests = result.getTestContext().getFailedTests();
List<ITestResult> falildMethodsDependedUpon = failedTests.getAllResults().stream()
.filter(t -> methodsDependedUponLst.contains(t.getName())).collect(Collectors.toList());
if(!falildMethodsDependedUpon.isEmpty()) {
throw new SkipException("Skipped because of dependency failure!");
}
}
}
StepLibrary.Java
```#QAFTestStep(description = "Call negative step")
public static void iCallNegativeStep() {
System.out.println("Enter into Neg");
Assert.assertEquals(true, false,"Called Negative step" );
}```
Console Log:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
log4j:WARN No such property [follow] in org.apache.log4j.FileAppender.
Added "QAFMethodSelector"
[ConfigurationManager] - ISFW build info: {qaf-Type=core, qaf-Revision=0b, qaf-Build-Time=24-Oct-2021 19:53:30, qaf-Version=3.1}
[ConfigurationManager] - Resource dir: D:\Temp\DelDepIssue\qaf-blank-project-maven-master\resources. Found property files to load: 6
[ConfigurationManager] - Resource dir: D:\Temp\DelDepIssue\qaf-blank-project-maven-master\resources. Found property files to load: 0
include groups []
exclude groups: [] Scanarios location:
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
**at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
Caused by: org.testng.TestNGException:
Method "scenarios.suite1.feature.Scenario2()[pri:2, instance:com.qmetry.qaf.automation.step.client.Scenario#2]" depends on nonexistent method "scenario1"**
at org.testng.DependencyMap.getMethodDependingOn(DependencyMap.java:65)
at org.testng.TestRunner.createDynamicGraph(TestRunner.java:1041)
at org.testng.TestRunner.privateRun(TestRunner.java:723)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
9 more
Preparing For Shut Down...
[ResultUpdator] - Using QAF Json Reporter
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.142 s
[INFO] Finished at: 2022-03-08T00:09:40+05:30
[INFO] ------------------------------------------------------------------------

While specifying dependency, method name value need to be exact same including upper/lower case, it is case sensitive. In your case when providing method name in dependsOnMethods you didn't provided name in the same case. For instance, method name is Scenario1 and in dependsOnMethods it is provided scenario1, if you observer it is not equal considering case sensitivity. That's why it complains that depends on nonexistent method scenario1. You can correct as sample below:
Scenario: Scenario1
Given COMMENT: "SC1"
And Call negative step
#priority:2 #dependsOnMethods:['Scenario1']
Scenario: Scenario2

Related

Jenkins Groovy error groovy.lang.MissingMethodException when trying to use readFile()

I've been getting an odd error in Jenkins when trying to run readFile() within a shared library, so that I can determine if a Dockerfile is pulling from ECR or docker hub. The error is :-
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.myorg.DockerManager.readFile() is applicable for argument types: (java.lang.String) values: [DockerServiceDescription/Dockerfile]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
at org.proj.DockerManager.login(/tmp/persistence/jobs/PROJ/jobs/builds/jobs/proj-subproj/branches/PROJ-4190/builds/47/libs/Global/src/org/me/DockerManager.groovy:26)
The method that's triggering the error is :-
/**
Login to docker
*/
void login() {
dockerfileHandle = readFile(dockerfile)
dockerfileLines = dockerfileHandle.readLines()
def dockerfileFROM = dockerfileLines.find{ dockerfileLine-> dockerfileLine =~ /^FROM / }
println("FROM: " + dockerfileFROM)
if (dockerfileFROM =~ /\.ecr\./ ) {
println("Using ECR")
ecrlogin()
} else {
println("Using DOCKER HUB")
dockerhublogin()
}
}
however that same code worked perfectly well within the pipeline code, it just breaks when moved into a shared library.
Any ideas?
Access to pipeline steps is done via an instance of CPSScript that represents the running pipeline. To use it in a class of shared library, you have to pass this into your library, either as constructor or method argument:
/**
Login to docker
*/
void login(def script) { // actually CPSScript, but that way, no import is needed
dockerfileHandle = script.readFile(dockerfile)
//...
}
This from your actual Jenkins file, you then call it like:
myInstance.login(this)
Also note that you println calls would result in output in the Jenkins logs, not the build logs, what you are aiming for is script.echo()

No such field found: field java.lang.String sinput error when accessing cppcheck plugin classes

]I am a junior dev trying to lear about Jenkins, I have been learning on my own for a couple of months. Currently I have a pipeline (just for learning purposes) which runs static analysis on a folder, and then publish it, I have been able to send a report through email using jelly templates, from there I realized it is posbile to instantiate the classes of a plugin to use its methods so I went to the cppcheck javadoc and did some trial and error so I can get some values of my report and then do something else with them, so I had something like this in my pipeline:
pipeline {
agent any
stages {
stage('analysis') {
steps {
script{
bat'cppcheck "E:/My_project/Source/" --xml --xml-version=2 . 2> cppcheck.xml'
}
}
}
stage('Test'){
steps {
script {
publishCppcheck pattern:'cppcheck.xml'
for (action in currentBuild.rawBuild.getActions()) {
def name = action.getClass().getName()
if (name == 'org.jenkinsci.plugins.cppcheck.CppcheckBuildAction') {
def cppcheckaction = action
def totalErrors = cppcheckaction.getResult().report.getNumberTotal()
println totalErrors
def warnings = cppcheckaction.getResult().statistics.getNumberWarningSeverity()
println warnings
}
}
}
}
}
}
}
which output is:
[Pipeline] echo
102
[Pipeline] echo
4
My logic (wrongly) tells me that if I can access to the report and statistics classes like that and uses their methods getNumberTotal() and getNumberWarningSeverity() respectively, therefore I should be able to also access the DiffState class in the same way and use the valueOf() method to get an enum of the new errors. But adding this to my pipeline:
def nueva = cppcheckaction.getResult().diffState.valueOf(NEW)
println nueva
Gives me an error:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field org.jenkinsci.plugins.cppcheck.CppcheckBuildAction diffState
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:425)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:409)
...
I can see in the javadoc there is a diffState class with a valueOf() method, but I cannot access to it is therre any other way to get the new errors between the last build and the current one?
I see 2 issues that could be causing this:
CppcheckResult doesn't have a member variable diffState so you can't access it obviously
If you check the javadoc of CppcheckResult the class does have:
private CppcheckReport report;
public CppcheckStatistics getReport()
and
private CppcheckStatistics statistics;
public CppcheckStatistics getStatistics()
there is no member (and getter method) for diffState so maybe try to call:
/**
* Get differences between current and previous statistics.
*
* #return the differences
*/
public CppcheckStatistics getDiff(){
my suggestion: cppcheckaction.getResult().getDiff().valueOf(NEW). Furthermore CppcheckWorkspaceFile does have a method getDiffState().
Please have a look at the script approval of your Jenkins (see here).
The syntax error might appear because Jenkins (Groovy Sandbox) blocks the execution of an (for the Jenkins) "unknown" and potential dangerous method.
Jenkins settings - Script Approval - Approve your blocked method

com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() threw an exception

Followed steps outlined here: https://qmetry.github.io/qaf/qaf-2.1.14/gherkin_client.html
<test name="Gherkin-QAF-Test">
<parameter name="step.provider.pkg" value="com.cucumber.steps" />
<parameter name="scenario.file.loc" value="resources/features/component/test/smoke.feature" />
<classes>
<class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
</classes>
</test>
Added feature file:
#Web
Feature: Google Search
#Smoke
Scenario: Search InfoStrech
Given I am on Google Search Page
When I search for "git qmetry"
Then I get at least 5 results
And it should have "QMetry Automation Framework" in search results
Added steps in java
#QAFTestStep(description = "I am on Google Search Page")
public void step1() {
System.out.println("I am on Google Search Page");
}
#QAFTestStep(description = "I search for {0}")
public void iSearchFor(String s) {
System.out.println("I search for " + s);
}
#QAFTestStep(description="I get at least {num} results")
public void iGet_inSearchResults(Integer n) {
System.out.printf("I get at least %d results\n", n);
}
#QAFTestStep(description="it should have {0} in search results")
public void itShouldHave_inSearchResults(String s) {
System.out.printf("it should have %s in search results\n", s);
}
Ran xml file as TestNG, getting error below:
The factory method class com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() threw an exception
org.testng.TestNGException:
The factory method class com.qmetry.qaf.automation.step.client.ScenarioFactory.getTestsFromFile() threw an exception
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:197)
at org.testng.internal.TestNGClassFinder.processFactory(TestNGClassFinder.java:223)
at org.testng.internal.TestNGClassFinder.processMethod(TestNGClassFinder.java:179)
at org.testng.internal.TestNGClassFinder.processClass(TestNGClassFinder.java:171)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:121)
at org.testng.TestRunner.initMethods(TestRunner.java:370)
at org.testng.TestRunner.init(TestRunner.java:271)
at org.testng.TestRunner.init(TestRunner.java:241)
at org.testng.TestRunner.<init>(TestRunner.java:192)
at org.testng.remote.support.RemoteTestNG6_12$1.newTestRunner(RemoteTestNG6_12.java:33)
at org.testng.remote.support.RemoteTestNG6_12$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_12.java:66)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:713)
at org.testng.SuiteRunner.init(SuiteRunner.java:260)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:198)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1295)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1273)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.FactoryMethod.invoke(FactoryMethod.java:167)
... 21 more
something else I've noticed. After an update to "Scenario" in feature file next to each line of conditions I see warning with text:
Step '********' does not have a matching glue code
To answer original question, easiest way is to start using maven template or ANT template.
Regarding your question in comment, of using testng annotations, when using BDD you can move that code into respective testng listener. For example, method with Before/AfterSuite annotation can be moved to Suite listener and Before/AfterMethod can be moved to Method Invocation listener.
When you are using QAF you may not required much of the code for driver management because qaf provides inbuilt feature of thread safe driver and resource management. You can take benefit of that with driver and element listeners and locator repository features. It is highly configurable, for example you can set property selenium.singletone to specify driver instance scope. Possible value can be Tests (testng xml test) or Methods (test mtehod) or Groups.

Process huge amount of data with grails and gpars

I have a Grails application which runs a job on a daily basis at midnight. In my example app I have 10000 Person records and do the following in the quartz job:
package threading
import static grails.async.Promises.task
import static groovyx.gpars.GParsExecutorsPool.withPool
class ComplexJob {
static triggers = {
simple repeatInterval: 30 * 1000l
}
def execute() {
if (Person.count == 5000) {
println "Executing job"
withPool 10000, {
Person.listOrderByAge(order: "asc").each { p ->
task {
log.info "Started ${p}"
Thread.sleep(15000l - (-1 * p.age))
}.onComplete {
log.info "Completed ${p}"
}
}
}
}
}
}
ignore the repeatInterval as this is only for testing purposes.
When the job gets executed I get the following exception:
2014-11-14 16:11:51,880 quartzScheduler_Worker-3 grails.plugins.quartz.listeners.ExceptionPrinterJobListener - Exception occurred in job: Grails Job
org.quartz.JobExecutionException: java.lang.IllegalStateException: The thread pool executor cannot run the task. The upper limit of the thread pool size has probably been reached. Current pool size: 1000 Maximum pool size: 1000 [See nested exception: java.lang.IllegalStateException: The thread pool executor cannot run the task. The upper limit of the thread pool size has probably been reached. Current pool size: 1000 Maximum pool size: 1000]
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.IllegalStateException: The thread pool executor cannot run the task. The upper limit of the thread pool size has probably been reached. Current pool size: 1000 Maximum pool size: 1000
at org.grails.async.factory.gpars.LoggingPoolFactory$3.rejectedExecution(LoggingPoolFactory.groovy:100)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:821)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1372)
at groovyx.gpars.scheduler.DefaultPool.execute(DefaultPool.java:155)
at groovyx.gpars.group.PGroup.task(PGroup.java:305)
at groovyx.gpars.group.PGroup.task(PGroup.java:286)
at groovyx.gpars.dataflow.Dataflow.task(Dataflow.java:93)
at org.grails.async.factory.gpars.GparsPromise.<init>(GparsPromise.groovy:41)
at org.grails.async.factory.gpars.GparsPromiseFactory.createPromise(GparsPromiseFactory.groovy:68)
at grails.async.Promises.task(Promises.java:123)
at threading.ComplexJob$_execute_closure1_closure3.doCall(ComplexJob.groovy:20)
at threading.ComplexJob$_execute_closure1.doCall(ComplexJob.groovy:19)
at groovyx.gpars.GParsExecutorsPool$_withExistingPool_closure2.doCall(GParsExecutorsPool.groovy:192)
at groovyx.gpars.GParsExecutorsPool.withExistingPool(GParsExecutorsPool.groovy:191)
at groovyx.gpars.GParsExecutorsPool.withPool(GParsExecutorsPool.groovy:162)
at groovyx.gpars.GParsExecutorsPool.withPool(GParsExecutorsPool.groovy:136)
at threading.ComplexJob.execute(ComplexJob.groovy:18)
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104)
... 2 more
2014-11-14 16:12:06,756 Actor Thread 20 org.grails.async.factory.gpars.LoggingPoolFactory - Async execution error: A DataflowVariable can only be assigned once. Only re-assignments to an equal value are allowed.
java.lang.IllegalStateException: A DataflowVariable can only be assigned once. Only re-assignments to an equal value are allowed.
at groovyx.gpars.dataflow.expression.DataflowExpression.bind(DataflowExpression.java:368)
at groovyx.gpars.group.PGroup$4.run(PGroup.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2014-11-14 16:12:06,756 Actor Thread 5 org.grails.async.factory.gpars.LoggingPoolFactory - Async execution error: A DataflowVariable can only be assigned once. Only re-assignments to an equal value are allowed.
java.lang.IllegalStateException: A DataflowVariable can only be assigned once. Only re-assignments to an equal value are allowed.
at groovyx.gpars.dataflow.expression.DataflowExpression.bind(DataflowExpression.java:368)
at groovyx.gpars.group.PGroup$4.run(PGroup.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
It seems as if the thread pool hasn't been set to 10000 while I use withPool(10000)
Can I perhaps do this computation (now only prints log statements) in chunks? If so how can I tell what the latest item was that was processed (e.g. where to continue) ?
I suspect the withPool() method has no effect, since the task is most likely using a default thread pool, not the one created in withPool. Try removing the call to withPool() and see if the tasks still run.
The groovyx.gpars.scheduler.DefaultPool pool (the default for tasks) in GPars resizes with tasks and has a limit to 1000 concurrent threads.
I'd suggest creating a fixed size pool instead, e.g.:
def group = new DefaultPGroup(numberOfThreads)
group.task {...}
Note: I'm not familiar with the grails.async task, only the core GPars ones, so things may be slightly different around PGroups in grails.async.
Trying to wrap processing of each element to task seems not optimal. Standard way to make parallel processing is split whole task to appropriate number of sub-tasks. You are starting with selection of this number. For CPU-bound task you might create N=number-of-processors tasks. Then you split task to N sub-tasks. Like this:
persons = Person.listOrderByAge(order: "asc")
nThreads = Runtime.getRuntime().availableProcessors()
size = persons.size() / nThreads
withPool nThreads, {
persons.collate(size).each { subList =>
task {
subList.each { p =>
...
}
}
}
}

Cant load data or create loader for FixtureLoader 1.2 in grails 2.3.6

I'm having problems getting Grails 2.3.6 to load fixtures during bootstrapping.
TRYING TO LOAD DATA THROWS A NULL POINTER
This the the code I tried to use:
class BootStrap {
def fixtureLoader
def init = { ServletContext ctx ->
environments {
...
development {
fixtureLoader.load("developmentTinySanityCheckData")
}
}
}
...
My project is in ~/grails-2.3.6-workspace/imca2
So I expect the above to load developmentTinySanityCheckData.groovy
from ~/grails-2.3.6-workspace/imca2/fixtures
That file definitely exists and is readable:
ls -lt ~/grails-2.3.6-workspace/imca2/fixtures
-rw-r--r-- 1 nick nick 83 2014-03-16 19:32 developmentTinySanityCheckData.groovy
And contains this minimal data:
fixture {
DoctorDecisionMakerType(com.ubergen.DecisionMakerType) {
code = "Doctor"
}
}
But the load fails with GrailsContextLoader NullPointerException: Cannot invoke load() on null object
[localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Cannot invoke method load() on null object
java.lang.NullPointerException: Cannot invoke method load() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
...
at BootStrap$_closure1_closure3_closure6.call(BootStrap.groovy)
at groovy.lang.Closure.call(Closure.java:405)
at BootStrap$_closure1_closure3_closure6.call(BootStrap.groovy)
...
CANT INJECT FIXTURELOADER?
I assumed the null object meant the fixture loader was not being instantiated; perhaps its not getting created by the dependency injector? I don't know if this is correct.
I tried to force the fixtureLoader to exist with:
class BootStrap {
def fixtureLoader
def init = { ServletContext ctx ->
fixtureLoader = ctx.getBean('fixtureLoader'); // INJECT LOADER
environments {
...
development {
fixtureLoader.load("developmentTinySanityCheckData")
}
}
}
...
But got - No signature of getBean() is applicable for argument [fixtureLoader]
ERROR context.GrailsContextLoader - Error initializing the application: No signature of method: org.apache.catalina.core.ApplicationContextFacade.getBean() is applicable for argument types: (java.lang.String) values: [fixtureLoader]
Versions:
ubuntu 10.04
eclipse / SpringToolSuite 3.4.0
grails 2.3.6
groovy 2.1.9 (for both project and workspace)
grails plugins:
build-test-data 2.1.2
fixtures 1.2
My original problem was that trying to call load on the fixtureLoader threw a null pointer. It appeared the fixtureLoader was unavailable, at least in development mode.
On checking in BuildConfig.groovy I found
plugins {
...
compile ":build-test-data:2.1.2"
test ":fixtures:1.2"
}
which presumably means the fixture loader is only created and available to use when the execution mode is test.
I corrected this to:
plugins {
...
compile ":build-test-data:2.1.2"
compile ":fixtures:1.2"
}
and the loader was created and worked in development mode too.

Resources