vineri, 2 octombrie 2015

Java: JUnit: Run a unit test inside a inner class -- using @RunWith(Enclosed.class)

package com.test;

//public class in the file
@RunWith(Enclosed.class)
public class GetCountryBasedOnIPDelegate {
    ...
}

//another class in the file (package access)
@RunWith(Enclosed.class)
class CSVGeoCodeNameProvider {
    ...
    public static class TestCSVGeoCodeNameProvider extends TestCase {
@Before
@Override
public void setUp() throws Exception {
//do some setups
                        ...
}
                //add some tests
@Test
public void testbuildCache() {
long countryIPRangeListSize = countryIPRangeList.size();
GenericUtils.debug(String.format("No. of items in file %s is %d",
GeoIPUtils.ipv4FilePath, countryIPRangeListSize));
assertNotSame(countryIPRangeListSize, 0);
assertNotNull(countryIPRangeList.get(new Long(18153472)).countryCode);
assertEquals(
countryIPRangeList.get(new Long(18153472)).countryCode,
"JP");
}
}
}

Niciun comentariu:

Trimiteți un comentariu