Static Analysis for Junit - junit

Is there any Eclipse plugin for Static analysis of Junits. I am looking for some best tool like PMD which checks for Junit practises and gives me a report on errors.

FindBugs has been described as a strong compliment to PMD and should cover JUnit tests since JUnit is still just Java. It's available from the University of Maryland.

Related

DAML smart contract uses JVM can we replace it to webaseembly?

Since all the blockchain technologies are looking forward to webassembly, its better to write contract which is fits in webassembly environment. But DAML currently uses JVM. Can we replace it to webassembly?
And whats the reason for using JVM rather than Webassembly?
We built a JVM based interpreter to be able to leverage the JVM ecosystem and the Java SDKs provided by many of the existing ledgers.
There is no fundamental obstacle to compiling DAML's core language DAML-LF to WebAssembly. As of 2019-06-20, support for this compilation has not yet been built.

JUnit 5 vs TestNG

We were using JUnit 4, but we had some problems with test grouping. For integration tests we had problems with running order. We had migrated to TestNG in February 2016.
Now we are starting a new independent module for our project and part of our team players wants JUnit 5. I believe it is much better than 4th (there are some new important features, but I see some problems too).
I do not want to use JUnit 5 because of fear of possible problems in our new application, because I have experience with 4th. But I have to be more flexible for the team, so before making a decision I need recommendations from users who have experience with JUnit 5.
TestNG objective is beyond unit test so it covers wider testing needs like Scenario Tests, Integration Test, Dependency Test, Ordering, Parallel Execution etc, but these feature are not supported in JUnit 5.
The JUnit 5 team have these above items in their road map, but they are extending a unit testing framework to support wider range of testing needs. Lets see how the new subsequent release of Junit 5 is able to address the wider testing need in comparison with TestNG
For Spring based application Junit fits best for doing the Unit and Integration Testing as it the default testing framework and Spring Provides lots of Test API with Mockito.
For general testing and Web Automation (Selenium) - TestNG is the de facto.
JUnit 5 introduced a lot of new features. Currently Intellij IDEA supports JUnit 5.
Take a look at article about integrating: Using JUnit 5 in IntelliJ IDEA.
There are some useful annotations now, like:
#Tag Used to declare tags for filtering tests, either at the class
or method level; analogous to test groups in TestNG or Categories in
JUnit 4
#DisplayName Declares a custom display name for the test class or test method
See more: JUnit 5 User Guide

Is JUnit considered a plugin?

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.

JUnit4OSGI with Equinox

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.

Running TestNg tests via JUnit TestSuite

Is it possible to execute TestNg tests in a JUnit TestSuite. I see a lot of web pages describing how to use TestNg to run JUnit but none the other way around.
No, only JUnit tests can be run in TestNG.
TestNG was initially developed as a replacement for JUnit with additional functionality and an emphasis on smooth migration. An ability to run JUnit tests was one of the tools for that smooth migration.
TestNG fully covers the functionality of JUnit and adds something new. And JUnit can not (currently?) emulate that difference in functionality.
You may check the comparison of these two libraries here.