Skip to content

Commit a56e3c7

Browse files
committed
Default test methods to Private. Closes #4658
1 parent e9edfc6 commit a56e3c7

File tree

3 files changed

+112
-69
lines changed

3 files changed

+112
-69
lines changed

Rubberduck.UnitTesting/CodeGeneration/TestCodeGeneratorStatics.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public partial class TestCodeGenerator
4040

4141
private static string TestMethodTemplate =>
4242
$@"'@TestMethod(""{DefaultTestCategory}"")
43-
Public Sub {{0}}() {RenameTestTodoComment}
43+
Private Sub {{0}}() {RenameTestTodoComment}
4444
On Error GoTo {TestFailLabel}
4545
4646
{ArrangeComment}
@@ -58,7 +58,7 @@ Exit Sub
5858

5959
private static string TestMethodExpectedErrorTemplate =>
6060
$@"'@TestMethod(""{DefaultTestCategory}"")
61-
Public Sub {{0}}() {RenameTestTodoComment}
61+
Private Sub {{0}}() {RenameTestTodoComment}
6262
Const {ExpectedErrorConstant} As Long = 0 {ExpectedErrorTodoComment}
6363
On Error GoTo {TestFailLabel}
6464
@@ -121,25 +121,25 @@ Option Private Module
121121
{{1}}
122122
123123
'@ModuleInitialize
124-
Public Sub {ModuleInitializeMethod}()
124+
Private Sub {ModuleInitializeMethod}()
125125
{ModuleInitializeComment}
126126
{{2}}
127127
End Sub
128128
129129
'@ModuleCleanup
130-
Public Sub {ModuleCleanupMethod}()
130+
Private Sub {ModuleCleanupMethod}()
131131
{ModuleCleanupComment}
132132
Set Assert = Nothing
133133
Set Fakes = Nothing
134134
End Sub
135135
136136
'@TestInitialize
137-
Public Sub {TestInitializeMethod}()
137+
Private Sub {TestInitializeMethod}()
138138
{TestInitializeComment}
139139
End Sub
140140
141141
'@TestCleanup
142-
Public Sub {TestCleanupMethod}()
142+
Private Sub {TestCleanupMethod}()
143143
{TestCleanupComment}
144144
End Sub";
145145
}

Rubberduck.UnitTesting/UnitTesting/TestDiscovery.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using Rubberduck.Parsing;
54
using Rubberduck.Parsing.Annotations;
65
using Rubberduck.Parsing.Symbols;
76
using Rubberduck.Parsing.VBA;
87
using Rubberduck.VBEditor;
9-
using Rubberduck.VBEditor.ComManagement.TypeLibsAPI;
108
using Rubberduck.VBEditor.Extensions;
119
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
1210

1311
namespace Rubberduck.UnitTesting
1412
{
15-
// FIXME make internal. Nobody outside of RD.UnitTesting needs this!
16-
public static class TestDiscovery // todo: reimplement using state.DeclarationFinder
13+
// FIXME make internal. Nobody outside of RD.UnitTesting needs this!
14+
public static class TestDiscovery // todo: reimplement using state.DeclarationFinder
1715
{
1816
public static IEnumerable<TestMethod> GetAllTests(RubberduckParserState state)
1917
{
@@ -37,10 +35,9 @@ public static IEnumerable<TestMethod> GetTests(IVBE vbe, IVBComponent component,
3735

3836
public static bool IsTestMethod(RubberduckParserState state, Declaration item)
3937
{
40-
return !state.AllUserDeclarations.Any(
41-
d => d.DeclarationType == DeclarationType.Parameter && Equals(d.ParentScopeDeclaration, item)) &&
42-
item.Accessibility == Accessibility.Public &&
43-
item.Annotations.Any(a => a.AnnotationType == AnnotationType.TestMethod);
38+
return !state.AllUserDeclarations.Any(d =>
39+
d.DeclarationType == DeclarationType.Parameter && Equals(d.ParentScopeDeclaration, item)) &&
40+
item.Annotations.Any(a => a.AnnotationType == AnnotationType.TestMethod);
4441
}
4542

4643
public static IEnumerable<Declaration> FindModuleInitializeMethods(QualifiedModuleName module, RubberduckParserState state)

0 commit comments

Comments
 (0)