Skip to content

Commit

Permalink
Simplify NoTestsPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Dec 7, 2016
1 parent fc9b3e5 commit bbcfc53
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public String getPluginName() {

@Override
public Optional<ExerciseDesc> scanExercise(Path path, String exerciseName) {
TestDesc test = new TestDesc(getExerciseName(path) + "Test", getPoints(path));
TestDesc test = new TestDesc(exerciseName + "Test", getPoints(path));
return Optional.of(
new ExerciseDesc(getExerciseName(path), ImmutableList.<TestDesc>of(test)));
new ExerciseDesc(exerciseName, ImmutableList.<TestDesc>of(test)));
}

private ImmutableList<String> getPoints(Path path) {
Expand Down Expand Up @@ -115,11 +115,4 @@ public Map<File, List<ValidationError>> getValidationErrors() {

@Override
public void clean(Path path) {}

private String getExerciseName(Path path) {
if (!getConfiguration(path).isSet("no-tests.exercise_name")) {
return "DefaultName";
}
return getConfiguration(path).get("no-tests.exercise_name").asString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public NoTestsPluginTest() {

@Test
public void readsConfigsProperly() {
Path project = TestUtils.getPath(getClass(), "notests");
System.out.println(project.toAbsolutePath().toString());
Path project = TestUtils.getPath(getClass(), "notests-points");
assertTrue(plugin.isExerciseTypeCorrect(project));
ExerciseDesc desc = plugin.scanExercise(project, "No Tests Exercise").get();
assertEquals(1, desc.tests.size());
Expand All @@ -35,4 +34,15 @@ public void readsConfigsProperly() {
RunResult runResult = plugin.runTests(project);
assertEquals(RunResult.Status.PASSED, runResult.status);
}

@Test
public void worksWithoutPoints() {
Path project = TestUtils.getPath(getClass(), "notests");
assertTrue(plugin.isExerciseTypeCorrect(project));
ExerciseDesc desc = plugin.scanExercise(project, "No Tests Exercise").get();
assertEquals(1, desc.tests.size());
assertEquals(0, desc.tests.get(0).points.size());
RunResult runResult = plugin.runTests(project);
assertEquals(RunResult.Status.PASSED, runResult.status);
}
}
1 change: 0 additions & 1 deletion tmc-langs-notests/src/test/resources/.Rprofile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
no-tests:
points:
- 1
- notests
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js/libs
browser.autorefresh.Chrome.INTEGRATED=true
browser.highlightselection.Chrome.INTEGRATED=true
file.reference.01_AsciiArtist-src=src
file.reference.01_AsciiArtist-test=test
files.encoding=UTF-8
site.root.folder=${file.reference.notests-src}
start.file=index.html
test.folder=${file.reference.notests-test}
web.context.root=/notests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.clientproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
<name>notests</name>
</data>
</configuration>
</project>
13 changes: 13 additions & 0 deletions tmc-langs-notests/src/test/resources/notests-points/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Oh noes, more lemmings!</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<p>solution space, hello world! :)</p>

</body>
</html>
6 changes: 1 addition & 5 deletions tmc-langs-notests/src/test/resources/notests/.tmcproject.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
no-tests:
exercise_name: "No Tests Exercise"
points:
- 1
- notests
no-tests: true

0 comments on commit bbcfc53

Please sign in to comment.