Grails 2.0.0 JUnit test #RunWith annotation equivalent - grails

So my understanding is that the grails testing framework is backed by JUnit tests.
I am trying to hook in cucumber-jvm, and the simplest way appears to be to have a JUnit test with the annotations #RunWith(Cucumber.class) and #Feature(".")
Those annotations appear to be ignored when I build test classes however. I suspect my groovy test classes aren't exactly picked up as JUnit test cases in the normal way.
Is there any way to get the equivalent of those annotations working in grails?

I am using Cucumber-JVM and Geb to functionally test some of our internal grails apps, using this grails plugin http://grails.org/plugin/cucumber
So far so good, I haven't used the annotations you mention however.

Related

Injecting custom logger into Specflow framework when using NUnit

Is there a way to inject custom logger into Specflow framework to capture beginnings and ends of the steps when using NUnit, or any other supported testing framework apart from XUnit? This help page (and Github issue) shows that with XUnit you can use its ITestOutputHelper to inject custom logger that would gather in the right order both Specflow logging as well as any additional logging that is present in steps.
I am using Context Injection and dependency injection with Autofac to setup all the parts of the test framework. And I understand how to inject any type of logger into Binding classes.
I wonder if it is possible to adapt current standard Microsoft.Extensions.Logging.ILogger<T> to be used for Specflow, step definitions, and other parts of the framework, so that it captures the full flow of the scenario. Or should I write Before/After hooks to get Scenario/Step definitions.

Does dart have a testing framework similar to Javascript's Jasmine?

Is there any test framework in Dart that is as robust as Jasmine
I did use pub test, but it is made me wanting something like Javascript's Jasmine.
Any suggestions?
The test package that you used is as robust as Jasmine. It is backed by tests, can run tests on multiple platforms (VM/server, browsers, Flutter), allows tagging, skipping, grouping, filtering by name, and more.
In what areas do you feel that Jasmine is more robust?

What do I need to start using specflow

I'm trying to use SpecFlow for a .net project. I'm new to SpecFlow. The Development team are using NUnit, so it would seem that SpecFlow would be a good option in conjunction with Cucumber. However, the Development team have come back say that SpecFlow cannot be used saying they do not have an API/Service that is available to use at the level required. Currently all of their automated tests are through the UI using Test Complete, I am keen to move to API level testing.
Can anyone explain to me why SpecFlow cannot be used, I'm sorry it's a newbie question but no one can answer it, I've asked everyone I can think of, surely the first steps would be to see if we can use SpecFlow with NUnit but perhaps not.
Can anyone give me a guide on my next steps, how can I be sure this isn't an option without righting it off without concern that it's just being blocked?
Thank you
SpecFlow has a unit test generator that generates unit test code for a variety of unit test frameworks. SpecFlow generates NUnit tests in its default configuration. The getting started page on specflow.org explains a quick way to get up and running with SpecFlow and NUnit, http://www.specflow.org/getting-started/.
If the UI is HTTP based, SpecFlow can be used with WebDriver or another browser automation framework to test the UI. This blog post provides an overview of how to get started with SpecFlow, NUnit and WebDriver, http://blogs.lessthandot.com/index.php/enterprisedev/application-lifecycle-management/using-specflow-to/
I am unclear on the API you want to test. If you could provide more information on the specific API and UI you are trying to test, I could possibly provide some code examples or references for you.
Is the API exposed through HTTP?
Is the UI a web, mobile, or desktop
application?
Have you tried to use SpecFlow at all?
SpecFlow doesn't run tests. It simply maps readable language to tests. If their test can be written as a nunit test, then SpecFlow is available to you to use. With no change, here is how it would look.
Scenario: Running 'testname'
Then I execute the test 'TestName'
You would map that to
[Then(#"I execute the test '(.*)'")]
public void ExecuteSpecificTest(string testname)
{
// Using reflection, execute the method listed
}
Obviously you would want to do better than that. You want a given, when, then so you clearly show the setup, action, and then compare expected verses actual result but it isn't necessary. Best practices however is another discussion.
To sum it up, code is code and SpecFlow simply maps to code. You can use WatiN, WebDriver, or anything else to hook into the UI or an API. SpecFlow doesn't care. It simple executes the methods without knowing what's inside.

Need workaround for Spock framework issues

I am facing the following problems while trying to use the Spock framework
Forced to inherit from Specification , is there any way to use annotations instead ?
Cannot execute individual tests , only option I found from internet is #IgnoreRest annotation, is there any other way to do it ?
ad 1. There is no way around inheriting directly or indirectly from Specification (for good reason).
ad 2. It depends on whether the environment that you are executing tests in (IDE, build tool) allows to execute individual (JUnit) tests.

Custom hamcrest matcher in unit tests

Having trouble implementing custom hamcrest matcher to use in Grails. Running the tests using my matcher fails with:
java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V
After a bit of googling it seems that this is caused by the order of the loaded libraries: JUnit and Hamcrest. I have added the following dependency to my BuildConfig.groovy:
dependencies {
test 'org.hamcrest:hamcrest-all:1.3'
}
Accordingly to instructions I was able to found, this could be fixed by making sure that hamcrest classes are loaded before JUnit ones. I do not know how to achieve this in Grails though or how to solve this in any other way.
Using Grails 2.2.1
This depends on the version of JUnit you're using. You can check this by looking in lib/junit/junit/jars. I think this is 4.10 by default. If so, please upgrade to 4.11. You can do this by explictly specifying it in the BuildConfig.groovy I believe:
dependencies {
test 'junit:junit:4.11'
test 'org.hamcrest:hamcrest-all:1.3'
}
For an explanation, before 4.11 a version of the hamcrest libraries were included in the JUnit distribution. This is no longer the case with 4.11, and you sometimes get a mismatch between class versions.

Resources