Posts

JUnit: Multiple Runners and Dependent Tests

repost from  https://bekce.github.io/junit-multiple-runwith-dependent-tests/ This way works for me, but in my scenario, the child test class need to access the parent's methods, which does not work under this solution. There are times that you may want to run a test case with multiple  @RunWith  annotations or you may have a bootstrap test class that you must run before every other test, such as bootstrapping the application during integration testing. JUnit by its nature does not have test class chaining but there is an easy solution. In this example I will mention  SpringJUnit4ClassRunner  which is used to bootstrap a Spring context, which is handy for integration testing, but this method applies to every case for JUnit, not just Spring. We also use  CasperRunner  to run  CasperJS  tests. However, CasperJS tests must run  after  the context has been initialized, and this order is not deterministic in JUnit. @RunWith ( Sp...

Java: Annotations tutorial with examples

Repost from:  https://beginnersbook.com/2014/09/java-annotations/ Java Annotations  allow us to add metadata information into our source code, although they are not a part of the program itself. Annotations were added to the java from JDK 5. Annotation has no direct effect on the operation of the code they annotate (i.e. it does not affect the execution of the program). In this tutorial we are going to cover following topics: Usage of annotations, how to apply annotations, what predefined annotation types are available in the Java and how to create custom annotations. What’s the use of Annotations? 1) Instructions to the compiler : There are three built-in annotations available in Java ( @Deprecated ,  @Override  &  @SuppressWarnings ) that can be used for giving certain instructions to the compiler. For example the @override annotation is used for instructing compiler that the annotated method is overriding the method. More about these built-in ann...

Java: Ant

Repost from:  https://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html This document provides a step by step tutorial for starting Java programming with Apache Ant. It does  not  contain deeper knowledge about Java or Ant. This tutorial has the goal to let you see, how to do the easiest steps in Ant. Content Preparing the project Four steps to a running application Enhance the build file Using external libraries Resources Preparing the project We want to separate the source from the generated files, so our Java source files will be in  src  folder. All generated files should be under  build , and there split into several subdirectories for the individual steps:  classes  for our compiled files and  jar  for our own JAR-file. We have to create only the  src  directory. (Because I am working on Windows, here is the Windows syntax—translate to your shell): md src The following simple Java class just print...