publicclassCalculator{publicintevaluate(String expression){int sum =0;for(String summand: expression.split("\\+"))
sum +=Integer.valueOf(summand);return sum;}}
CalculatorTest.java
importstaticorg.junit.Assert.assertEquals;importorg.junit.Test;publicclassCalculatorTest{@TestpublicvoidevaluatesExpression(){Calculator calculator =newCalculator();int sum = calculator.evaluate("1+2+3");assertEquals(6, sum);}}