Skip to content

Commit

Permalink
Issue checkstyle#13345: Enable examples tests for MissingCtorCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitKumarDeoghoria authored and romani committed Nov 4, 2024
1 parent d7c12da commit ddb3546
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@

package com.puppycrawl.tools.checkstyle.checks.coding;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;

@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class MissingCtorCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
Expand All @@ -34,9 +32,9 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {

"23:1: " + getCheckMessage(MissingCtorCheck.MSG_KEY),
};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.coding.missingctor;

// xdoc section -- start
class ExampleOk { // OK
public class Example1 {
private int a;
ExampleOk(int a) {
Example1(int a) {
this.a = a;
}
}
class ExampleDefaultCtor { // OK
class ExampleDefaultCtor {
private String s;
ExampleDefaultCtor() {
s = "foobar";
}
}
class InvalidExample { // violation, class must have a constructor.
class InvalidExample { // violation, 'Class should define a constructor'
public void test() {}
}
abstract class AbstractExample { // OK
public abstract void test() {}
abstract class AbstractExample {
public abstract void test();
}
// xdoc section -- end
12 changes: 6 additions & 6 deletions src/xdocs/checks/coding/missingctor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@
</source>
<p id="Example1-code">Example:</p>
<source>
class ExampleOk { // OK
public class Example1 {
private int a;
ExampleOk(int a) {
Example1(int a) {
this.a = a;
}
}
class ExampleDefaultCtor { // OK
class ExampleDefaultCtor {
private String s;
ExampleDefaultCtor() {
s = &quot;foobar&quot;;
}
}
class InvalidExample { // violation, class must have a constructor.
class InvalidExample { // violation, 'Class should define a constructor'
public void test() {}
}
abstract class AbstractExample { // OK
public abstract void test() {}
abstract class AbstractExample {
public abstract void test();
}
</source>
</subsection>
Expand Down
4 changes: 2 additions & 2 deletions src/xdocs/checks/coding/missingctor.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/missingctor/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/missingctor/Example1.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example1-code">Example:</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/missingctor/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/missingctor/Example1.java"/>
<param name="type" value="code"/>
</macro>
</subsection>
Expand Down

0 comments on commit ddb3546

Please sign in to comment.