Can anyone please tell me where exactly spock_sharedField__browser field should be declared or initialized in Geb testing framework?
Related
When I use grails 2, I use the functional plugin to create the function test and I use Rest-client-builder to send post and get request. The function test itself can start up the server.
However, When I upgrade to grails 3. the built in geb framework can help me create the function test. However, I don't know how i can send the post and get request. And the function test itself can not start up the server. I have to run-app first and then run the test. Does anyone know what should I do function post/get test via grails 3?
Thanks very much
And the function test itself can not start up the server.
You haven't described the details of what you are doing so I don't know why it might not be working for you, but it certainly can be made to work. You probably want to create integration tests and mark them with #Integration. We have a lot of examples in the project at https://github.com/grails/grails3-functional-tests. Look in https://github.com/grails/grails3-functional-tests/tree/master/app1/src/integration-test/groovy/functionaltests. A simple example that should be easy to read is at https://github.com/grails/grails3-functional-tests/blob/master/app1/src/integration-test/groovy/functionaltests/HomeSpec.groovy.
I hope that helps.
Does anyone know if Unit Spec is still available on Grails-2.4.4? https://code.google.com/p/spock/source/browse/branches/groovy-1.7/spock-grails-support/src/main/groovy/grails/plugin/spock/UnitSpec.groovy?r=1149
I wanted to use UnitSpec's loadCodec() method from within a Spec class of mine, but UnitSpec doesn't seem to be available anymore, is there a workaround for this?
Thanks!
#dmahapatro, I didn't really know there was a mockCodec method.
Thanks to your tip and this post (Grails unit testing custom codec using Spock), I figured out how to use GrailsUnitTestMixin#mockCodec.
Thanks!
I have a domain class called Profile. I tried to access its properties in the following code:
Profile p = new Profile()
// doing some changes
p.name = 'Larry'
//....
p.save(flush:true)
// then I print out the properties, and this line of code raises warning.
print p.properties
Then the following warning message shows up:
WARN security.Security - An attempt was made to use the grailsSecurity bean, but there is no security bridge implementation defined. You must install a security plugin and/or provide a grailsSecurityBridge bean.
I do have a spring-security plugin. So I'm not so sure about the meaning of this security issue. A different security plugin?
I cannot find any information related to this issue. Could someone help me please? Thank you!
I did a search on "grailsSecurityBridge bean". The results led me to the Grails plugin platform-core:1.0.RC5, which was installed in my application.
So I created another project and tried to access the profile properties with and without the plugin. And the result showed that the plugin was the cause.
I'm not sure if I need this plugin in my application but at least I know the cause now.
Update:
I'm using another plugin "email confirmation" which depends on the platform-core plugin. So uninstall the platform-plugin is not the solution.
Instead, we should implement the graisSecurityBridge bean. Just follow the following links:
http://grailsrocks.github.io/grails-platform-core/guide/security.html#security_implementing_bridge
http://grailsrocks.com/blog/2012/03/28/hooking-up-platform-core-security-api-to-your-security-provider
The problem
I'm struggling to make my Fluent Validation RuleSet work, currently it doesn't, and I don't have any idea why is that happening, everything seems all right. I would like to somehow step into the code that performs the validation itself, but RuleSet lambdas are ExpressionTrees which doesn't provide even poor debugging experience.
The question
Is there a way to debug RuleSet logic to see what's happening inside RuleSets?
FluentValidation is open source, so theoretically you could download the code from the repo at https://github.com/JeremySkinner/FluentValidation and then load up the solution, reference it directly, then step through.
Hopefully this will get you where you need to be, but I'm sure someone here could help if you provided your rules and maybe some unit tests that show the failures.
The current version of FluentValidation allows you to unit test your validators by using the TestValidate extension method. There is also an async version available.
Calling this method, passing an object to validate, will return a TestValidationResult<> object which has 2 useful methods ShouldHaveValidationErrorFor and
ShouldNotHaveValidationErrorFor that can be used to check if tests passed or failed.
The documentation can be found here https://docs.fluentvalidation.net/en/latest/testing.html
There is no way to debug Fluent Validator code with Visual Studio tools.
You need to comment the specific part of code (RuleFor) that you want to test. Keep doing it until all rules are tested.
You can debug Fluent Validation a little bit. When the validator is injected you can debug into the constructor like this:
At least then you know your services are registered in DI.
If you have a Custom validator, you can put a breakpoint there as well and actually break when the validation is called.
RuleFor(x => x.InstallLocation.Address.StreetAddress)
.NotEmpty()
.Custom(InstalledAtPhysicalStreetAddress);
I am working with the Grails Authentication plugin and trying to add a domain class from the plugin into my GORM. I am able to use plugin objects in my application when importing them with, "import com.grailsrocks.authentication.AuthenticationUser", but getting "unable to resolve class" exception when trying to access my application objects from the plugin (I am trying to use the domain class "User" and my import command is "import blap.User" - package name is blap). Both import commands work from the shell, and the import statement is not triggering an error in STS.
I am new to grails, so I'm probably doing something very wrong. But, at this point I am running out of ideas, so any help would be greatly appreciated. Thanks!
Vitaly
While I haven't used the Grails Authentication plugin before, I don't think you should be modifying the plugin classes. In general, you should extend the plugin class you want to modify in your application and use your application class instead.
Actually, from reading the docs, it looks like you should use the event handling to modify the plugin behavior.
From the plugin docs:
The default AuthenticationUser domain class is minimal. If you want to change constraints or add fields (you may consider using a separate class instead for extra user data) you just redefine the onNewUserObject event and return your own instance of a domain class or similar wrapper around another authentication database such as LDAP