jeudi 1 août 2019

How to read and test a class from java extension file in junit? How can I access that class for testing?

In a software for mutation testing, a lot of mutants of java extension files (like mutant01.java) are created. Now I need to test these files by using jUnit4. I'm trying to find out the way that I will be able to read the file and then access a specific class from that file, and perform jUnit testing on it. But I need help to do it?

I had found the ways that only results that my file is uploaded but I'm not be able to access the contents or specific class from that file.

@Test
public void testReadFileWithClassLoader(){
    try {
        ClassLoader classLoader = this.getClass().getClassLoader();
        File file = new File(classLoader.getResource("arith.java").getFile());
        Class<? extends File> f=file.getClass();
        assertTrue(file.exists());

I'm expecting that I become able to access the class from a java extension file and then perform junit testing on it but actually I'm stuck on it.

Aucun commentaire:

Enregistrer un commentaire