Skip to content

Commit

Permalink
Change getDebugFileName to protected function for testing.
Browse files Browse the repository at this point in the history
- Remove reflection test.
- Thanks to @ataylor284
  • Loading branch information
JSpiner authored and smith.jspiner committed Oct 17, 2021
1 parent 9eb5223 commit 68d3969
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static boolean fileContentEquals(File file, String code) throws IOExcept
return false;
}

private static String getDebugFileName( String file ) {
protected static String getDebugFileName( String file ) {
return file.replaceFirst( ".js$" , "-debug.js" );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,19 @@

import org.testng.annotations.Test;

import java.lang.reflect.Method;

import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;

public class CodeFileGeneratorTest {

private String getDebugFileName(String file) {
try {
Method method = CodeFileGenerator.class.getDeclaredMethod("getDebugFileName", String.class);
method.setAccessible(true);
Object result = method.invoke(null, file);
return (String) result;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}

@Test
public void getDebugFileNameTest() {
assertEquals(
"john.jspiner",
getDebugFileName("john.jspiner")
CodeFileGenerator.getDebugFileName("john.jspiner")
);
assertEquals(
"app-debug.js",
getDebugFileName("app.js")
CodeFileGenerator.getDebugFileName("app.js")
);
}
}

0 comments on commit 68d3969

Please sign in to comment.