Is there a better way to get TestEngine instance using the testEngineId in JUnit 5? - junit5

I'm developing a TestExecutionListener where I'd like to obtain the version of the TestEngine that executed that test (e.g., the TestEngine version).
I'm currently discovering all the available TestEngine using the ServiceLocator approach (similar to what the Launcher does) and iterating to extract those located engines into a map. Then, using the testEngineId, I can get the version.
I think this approach is too overkill, but I couldn't find anything better.
Is there a public API to get a TestEngine instance based on the testEngineId?

Related

What is the equivalent of karate.get() in Java?

I have created a Java object in karate scripts using Java interop and have used it as required.
Now, I want to retrieve that same instance in another Java class. Is there a way to do that?
In karate, we have an equivalent method like karate.get('objectName'). Is there any equivalent API available in Karate lib?
Please assume that the answer is no. I'd like to mention that the whole point of creating Karate was to avoid using Java for API test automation. I say this because I suspect based on your questions that you have made the same mistake I've seen a few other teams make - which is attempting to make Karate work like the Seleniums and Rest Assureds of the world. That always ends badly. And what's worse is that these teams blame Karate for that and go around telling everyone. I'd rather have that not happen - so if this is a "blocker" please consider using some other tool.
If you are already calling Java, you have plenty of ways to pass objects around right? Just use that and don't over-complicate your tests. Or you can use the "singleton" pattern, nothing to do with Karate, you can look it up.

Karate Java API for Match methods

Background:
I noticed this interesting post on Twitter about a Java API for Karate: https://twitter.com/ptrthomas/status/1344290316212342784
I don't have a twitter account so unable to reply - hope you don't mind me asking here instead.
I have used Karate (with the parallel runner, feature files and all) in one work project and it is a joy to use - and a few folks in the workplace are very impressed with the complex JSON assertion. We are achieving a level of JSON response field coverage for that project that is not possible with other frameworks (IMO).
I've now been tasked with improving an older test project which uses JUnit + RESTAssured, but has quite limited field assertions. I am unable to fully convert it to raw Karate (too many tests, not enough time), but I'm keen to explore the possibility of supplementing what is there already with the Karate Java API mentioned in above twitter post.
For example - for an existing test which gets a Response using RESTAssured, it would be nice for me to somehow use the 'contains' method (or any of the methods in Match class) in Karate to assert that response, as it is the best JSON assertion tool I have come across.
Questions:
Off the bat - is this a practice you would recommend for my use case? Let me know if you think this is an anti-pattern. I ask this because the example here (https://github.com/ptrthomas/karate-showcase) is not using RESTAssured to get the response and my use case is a bit different.
If its worth exploring - I assume this stuff will be available in v1.0.0? (I see public methods such as that are on the develop branch, but couldn't see it on the v1.0.0 github thread).
but I'm keen to explore the possibility of supplementing what is there already with the Karate Java API mentioned in above twitter post.
That's very interesting and you have got me also thinking about this potentially interesting way to introduce Karate to legacy projects. I do get this question on how to magically migrate existing RA tests a lot.
I would recommend it. You can expect a 0.9.9.RC3 next week that should have all the assertions you want. And the API has been simplified so you don't need to call isTrue() etc.
We plan to have better examples (maybe you can help) but for now, use this as a starting point (look at the last test / very end of the file): MatchTest.java
If you want to get started now (which I recommend and you can provide more feedback) do take a look at the developer guide: https://github.com/intuit/karate/wiki/Developer-Guide

Best structure to use both seleniumbackedrc and webdriver

We have recently moved to Selenium Web Driver. We have loads of tests written in selenium Rc which are now working fine using webdriverbackedselenium API. Now I am planning to move to web driver. Can you please guide what the is best approach to shift. Either completely move the code to use web driver but it requires a lot of effort. Or use both. It means I need to keep wrapping and unwrapping the driver. Totally confused about the layout of structure. Please guide.
It really depends on how your old tests were organized. If you used Page Object Pattern in your old tests migration to WebDriver should not be so difficult. Just create base class for all your page model classes and put in it all the logic that you need to initialize your page instance using Page factory. After that you can rewrite old page classes one by one preserving old interface in order to reduce amount of changes in the tests.

Grails functional test dependency injection

I am quite new to Grails, but I am using this plugin for functional testing:
http://www.grails.org/Grails%20Functional%20Testing
I am wondering how to inject a service such as the messageSource or or the applicationContext so I can have access to different resources. A simple example would be that I want to write a functional test to check if the text on the website is equal to the message string in the messages.properties file. Right now I cant seem to find an out of the box way of doing that. Can you advice on something? Also is that the best functional testing framework for grails since its quite limited?
You may want to try Geb instead it is a good framework that has nice support and good docs. But the one items to remember is that functional tests are running against the full stack so some tests you may find work better as integration or unit tests.
You can use the remote control plugin in grails to modify your grails application on the fly. It uses the groovy remote control mechanism and serializes results for functional tests

Flash Builder 4.5 for PHP does not generate CRUD php classes for services while the previous version did?

I recently upgraded to Flash Builder 4.5 for PHP since I’m working on a big PHP/Flex project and thought that it would be easier to integrate the two.
What do you know? The feature that generate the php class to feed a flex/PHP service trough AMF is appears to be missing!
Time to downgrade or am I overlooking something?
I believe it's still there, but that feature should only be used for building a test application. It breaks a lot of best practices such as creating the connection in the class (it should be injected or retrieved from an outside class that manages the DB) and it puts the database definition info in the class (username, password, etc.). I believe that when you use that feature that a popup tells you that it is not intended for production use. When building a service class it is best to define your classes based off of the functionality you need to provide.