which tools can be used to make unit test on Wirecloud widgets and operators?
Any of Javascript testing frameworks are valid?
You can use any JavaScript framework for unit testing WireCloud widgets and operators. You can find a mock of the API provided by WireCloud in this repo. You can also take a look into some of the Widgets using this mock (jointly with jasmine).
Related
I want to write the business logic of my CodenameOne application using JUnit 5. But when I try to run any unit test in Intellij, the simulator is started with the app instead of the unit tests.
Did anybody figure out how to setup Intellij such that the unit tests can be run without triggering the Ant build?
Codename One has its own unit test API and test recorder, generally you should use that for your testing as it allows you to test everything including the GUI.
See this for further details on using the testing framework.
You could probably use JUnit for the pure business logic but I'm not sure what benefit it would provide.
My thought is that "JUnit is a framework for testing java applications and is typically implemented as plugins (to popular IDEs)", but can't it also be considered a standalone testing tool if implemented as a standalone (although it might be a stupid idea)?
No, JUnit is a testing framework.
You would still require a "runner" to run your JUnit tests, be it Maven or a similar.
There are stand alone runners available so you can execute tests without build tools or an IDE.
I wonder if someone can point me to a good tutorial/sample/best practices about using JUnit4OSGI with Equinox as the OSGI container?
I already downloaded JUnit4OSGI and started writing sample test cases, but what I'm looking for are answers for questions like:
1- How to structure the unit tests? put it in a separate bundle or each bundle should have its own unit tests?
2- How to run the unit tests using a maven plug-in? Or is there a better way?
3- How to run the unit tests during development as I understand there is a command line specific to Felix only.
Thanks.
I cannot help with Junit4OSGi but I can offer an alternative that works with Maven. It has the following parts:
testRunner: A module that can run tests if they are registered as OSGi services
testRunner-junit4: Junit4 engine for the testrunner module
eosgi-maven-plugin: A maven plugin that can use the modules above and run the unit tests during integration-test phase in equinox, felix or a custom container
richconsole: A simple module that makes it possible to drop modules to the OSGi container. Together with the maven plugin they can be used to update maven dependencies in the container without restarting it
Testrunner itself does not really care what technology offered the OSGi service. It could be blueprint, DS, iPojo or whatever. It needs the followings:
eosgi.testId service property must be provided. This is a unique value
eosgi.testEngine service property must be provided. In case of JUnit this is junit4
In case of JUnit, the class/interface must be annotated with JUnit annotations. Beware that blueprint wraps the service objects (I do not know if iPojo does it as well) so you have to implement an interface in your class and annotate the functions in the interface instead of the class
I think the best place to start is the maven usage site. At the moment the osgi-liquibase-bundle project uses the most up-to-date versions. Without knowing what it does, it is a good example of configuration (project hierarchy and pom.xml configuration).
All the modules and the plugin is available at maven-central.
Update
A guide about the usage of the tools is available at http://cookbook.everit.org
Update 2016.12
There is an Eclipse plugin now that allows the user to start/stop/debug/upgrade the OSGi environments specified by eosgi-maven-plugin. The usage of the plugin has benefits over the usage of richconsole.
Cookbook will be updated soon to use the Eclipse plugin instead of richconsole.
I'm new to AS3 and Flex, but I am creating a mobile app with them in FlashDevelop. I want to add some unit tests, but I can't find any really good frameworks or documentation on it. I saw a little bit on FlexUnit and AsUnit, but both seem to be a few years old, and there isn't much documentation on using them in FlashDevelop.
Is there a good framework I can use for unit testing here? Even if I can't test the UI layer, I'd like to at least make sure my backend functions work correctly.
If you are testing backend functions, then you generally want to use the testing framework of whatever backend you are using. If you want Flex to test your backend functions, then you aren't Unit Testing, you are Integration Testing. While FlexUnit seems old, it still performs well at serving its purpose. The usage of FlexUnit should be independent of your IDE, you may just have to do more typing.
You can try to use the Flexunit4.0 for testing the business logic on the client side mixing it with the Mockito. None of these actually support testing the UI.
i've never tried to test the backend services with the Unit testing because of the authentication issues, but we created another testing UI for testing the services, This UI has a tons of screens, each screen to test different services.
I've seen that there is a ServiceBrowser for amfphp, i'm not sure if this can be used for Java or other platforms.
Other ways of testing the UI is by automation testing, use flexmonkey, selenium for that.
i have been given a project to write test cases for restful service using junit. The restful service provides json data as output.I am new to this, although i have attained basic knowledge but still do not know what to test.Please help.
Ok. So there are several things that could / should be done.
Unit test the Controller directly. Mock all other classes.
Attempt to use any framework provided testing utilities to test how the controller interacts with the framework. An example of this is Spring's MockMVC. For an example, check out the "correct" answer to this question: JUnit test for ExceptionHandler
Both of the above to not require a deployed service to test and so work well in the test phase of maven.
Additionally, although this would be an integration test, you could write JUnit tests using RestTemplate to hit the running service and verify the results. Since this has the external dependancy that the service is deployed and doesn't use any mocks it is an integration test. That said, it is a very valid set of tests and can be written in JUnit. However, these tests should be named (or categorized) as Integration tests so that they can be isolated from the tests that do not have external dependancies.
The fact that the service provides JSon should not be a big deal. Just use Jackson to unmarshal it into a domain object and verify the values are what you expect.
Send request and test the response. You may use restfuse.