| 1 |
|
package com.puppycrawl.tools.checkstyle.api; |
| 2 |
|
|
| 3 |
|
import com.puppycrawl.tools.checkstyle.DefaultConfiguration; |
| 4 |
|
import junit.framework.TestCase; |
| 5 |
|
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 6 |
|
public class AutomaticBeanTest extends TestCase |
| 7 |
|
{ |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 8 |
|
private class TestBean extends AutomaticBean |
| 9 |
|
{ |
| 10 |
|
private String mName = null; |
| 11 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 12 |
0
|
public void setName(String aName)... |
| 13 |
|
{ |
| 14 |
0
|
mName = aName; |
| 15 |
|
} |
| 16 |
|
} |
| 17 |
|
|
| 18 |
|
DefaultConfiguration mConf = null; |
| 19 |
|
|
| 20 |
|
TestBean mTestBean = new TestBean(); |
| 21 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 22 |
1
|
public void setUp()... |
| 23 |
|
{ |
| 24 |
1
|
mConf = new DefaultConfiguration("testConf"); |
| 25 |
|
} |
| 26 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
1
PASS
|
|
| 27 |
1
|
public void testNoSuchAttribute()... |
| 28 |
|
{ |
| 29 |
1
|
mConf.addAttribute("NonExisting", "doesn't matter"); |
| 30 |
1
|
try { |
| 31 |
1
|
mTestBean.configure(mConf); |
| 32 |
0
|
fail("AutomaticBean.configure() accepted nonexisting attribute name"); |
| 33 |
|
} |
| 34 |
|
catch (CheckstyleException ex) |
| 35 |
|
{ |
| 36 |
|
|
| 37 |
|
} |
| 38 |
1
|
assertEquals(mTestBean.mName, null); |
| 39 |
|
|
| 40 |
|
} |
| 41 |
|
} |