Tags » JUnit

Parameterized JUnit tests and Spring contexts

I like Spring. I really like using it and I use it quite often. One of its neat features is creating Spring managed contexts for JUnit test cases. 594 more words

Java

How to Cucumber : Test Reporting Plugin with Maven and Java

It is often useful to show the results of our tests to others people who are not developers, like managers or executive. This tutorial shows how to integrate a Cucumber reporting a Java plugin in Maven project. 1,026 more words

Tutorials

Java Junit Assume

public class JunitAssumeSampleTest {
    
    @Test
    public void shouldSkipTest() {
        boolean isIntegrationEnvironment = false;

        // assume
        Assume.assumeTrue("This test should only run in integration environment", isIntegrationEnvironment);

        // this code will NOT be executed
        throw new RuntimeException();
    }

    @Test(expected = RuntimeException.class)
    public void shouldRunTestTest() {
        boolean isIntegrationEnvironment = true;

        // assume
        Assume.assumeTrue("This test should only run in integration environment", isIntegrationEnvironment);

        // this code will be executed
        throw new RuntimeException();
    }
}
Java

Junit @ClassRule and integrations tests

JUnit Rule API was introduced in version 4.8 but in this version rules can only be applied to a test method not to a Test class or a test suite. 239 more words

Programming

JVM & OS Memory check

//src/main/java

package com.java.memory;

import java.lang.management.OperatingSystemMXBean;

public class MemoryInfo {

Runtime runtime= Runtime.getRuntime(); // jvm resource

com.sun.management.OperatingSystemMXBean bean =

(com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean(); // os resource… 306 more words

Java

Unit testing String Class's Immutability and StringBuilder Class's mutability.

String and StringBuilder are two popular java classes and both are meant for playing with strings of characters. And the major difference between them is String is immutable while StringBuilder is mutable. 266 more words

Java

Selenium WebDriver Installation

The Selenium Web driver can be loaded and accessed directly in Java and other programing languages to build more a more comprehensive suite of tests. 143 more words

Selenium