Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon Bodner jonbodner

View GitHub Profile
View code_coverage_13.java
public class CalculatorImpl implements Calculator {
public CalculatorImpl() {
}
@Override
public double process(String expression) {
String[] tokens = expression.split(" ");
Deque<String> operators = new ArrayDeque<>();
Deque<Double> numbers = new ArrayDeque<>();
try {
View code_coverage_12.java
@Parameters(name = "{index}: CalculatorTest({0})={1}, throws {2}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{"1 + 1", 2, null},
{"1 + 1 + 1", 3, null},
{"1–1", 0, null},
{"1 * 1", 1, null},
{"1 / 1", 1, null},
{"( 1 + 1 )", 2, null},
{"+", 0, new CalculatorException("Invalid expression: +")},
View code_coverage_11.java
@RunWith(Parameterized.class)
public class CalculatorTest {
@Parameters(name = "{index}: CalculatorTest({0})={1}, throws {2}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{"1 + 1", 2, null},
{"1 + 1 + 1", 3, null},
{"1–1", 0, null},
{"1 * 1", 1, null},
{"1 / 1", 1, null},
View code_coverage_10.java
public class CalcControllerTest {
@Test
public void result() {
CalcController c = new CalcController(new Calculator() {
@Override
public double process(String expression) {
if (expression.equals("1 + 1")) {
return 2;
}
View code_coverage_9.java
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
@Autowired
ApplicationContext ac;
@Test
public void contextLoads() {
Calculator calculator = ac.getBean(Calculator.class);
View code_coverage_8.xml
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
View code_coverage_7.xml
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
View code_coverage_6.java
package com.example.demo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoApplicationTests {
View code_coverage_5.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
View code_coverage_4.java
package com.example.demo;
import com.example.demo.calculator.Calculator;
import com.example.demo.calculator.CalculatorImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class DemoApplication {
You can’t perform that action at this time.