├── .vscode
├── settings.json
├── tasks.json
└── launch.json
├── assets
├── prettier_test_logger.png
└── no_prettier_test_logger.png
├── .travis.yml
├── src
└── PrettierTestLogger
│ ├── LogEntry.cs
│ ├── PrettierTestLogger.props
│ ├── PrettierTestLogger.csproj
│ ├── LogEntryBuilder.cs
│ └── TestLogger.cs
├── CHANGELOG.md
├── .appveyor.yml
├── test
└── PrettierTestLogger.Tests
│ ├── PrettierTestLogger.Tests.csproj
│ └── LogEntryBuilderTests.cs
├── README.md
├── PrettierTestLogger.sln
└── .gitignore
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/assets/prettier_test_logger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saintedlama/prettiertestlogger/HEAD/assets/prettier_test_logger.png
--------------------------------------------------------------------------------
/assets/no_prettier_test_logger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saintedlama/prettiertestlogger/HEAD/assets/no_prettier_test_logger.png
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | mono: none
3 | dotnet: 2.1
4 | script:
5 | - dotnet restore
6 | - dotnet build
7 | - dotnet test --logger prettier test/PrettierTestLogger.Tests/PrettierTestLogger.Tests.csproj
8 |
--------------------------------------------------------------------------------
/src/PrettierTestLogger/LogEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestPlatform.ObjectModel;
3 |
4 | namespace PrettierTestLogger
5 | {
6 | public class LogEntry
7 | {
8 | public string TestClass { get; set; }
9 | public string Test { get; set; }
10 | public TestOutcome Outcome { get; set; }
11 | public int DurationMs { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/test/HumanizedTestlogger.Tests/HumanizedTestlogger.Tests.csproj"
11 | ],
12 | "problemMatcher": "$msCompile"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/src/PrettierTestLogger/PrettierTestLogger.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Prettier.TestLogger.dll
6 | PreserveNewest
7 | False
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file. See [versionize](https://github.com/saintedlama/versionize) for commit guidelines.
4 |
5 |
6 | ## 1.1.1 (2018-10-5)
7 |
8 | ### Bug Fixes
9 |
10 | * fix abbrevation handling and make the logger more safe to exceptions
11 |
12 | ## 1.1.0 (2018-10-4)
13 |
14 | ### Bug Fixes
15 |
16 | * remove superfluous Console.Writeline
17 |
18 | ### Features
19 |
20 | * use props file to copy the Prettier.TestLogger.dll on build and to make dotnet test know the logger
21 |
22 |
--------------------------------------------------------------------------------
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | image: Visual Studio 2017
2 | branches:
3 | only:
4 | - master
5 | before_build:
6 | - cmd: dotnet --version
7 | - cmd: dotnet tool install coveralls.net --global
8 | build_script:
9 | - cmd: dotnet build
10 | test_script:
11 | - cmd: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger prettier test/PrettierTestLogger.Tests/PrettierTestLogger.Tests.csproj
12 | - ps: csmacnz.Coveralls --opencover -i C:\projects\prettiertestlogger\test\PrettierTestLogger.Tests\coverage.opencover.xml --repoToken $env:COVERALLS_REPO_TOKEN --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID
13 | deploy: off
14 |
--------------------------------------------------------------------------------
/test/PrettierTestLogger.Tests/PrettierTestLogger.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 | runtime; build; native; contentfiles; analyzers
12 | all
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PrettierTestLogger
2 |
3 | Prettier formatting for your dotnet core tests. Tested with xunit.
4 |
5 | [](https://travis-ci.org/saintedlama/prettiertestlogger)
6 | [](https://ci.appveyor.com/project/saintedlama/prettiertestlogger)
7 |
8 | [](https://coveralls.io/github/saintedlama/prettiertestlogger?branch=master)
9 |
10 | ## Motivation
11 |
12 | Get output like this
13 |
14 | 
15 |
16 | instead of this
17 |
18 | 
19 |
20 | ## Installation
21 |
22 | ```bash
23 | dotnet add package PrettierTestLogger
24 | ```
25 |
26 | ## Usage
27 |
28 | ```bash
29 | dotnet test --logger prettier
30 | ```
31 |
--------------------------------------------------------------------------------
/src/PrettierTestLogger/PrettierTestLogger.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | Prettier.TestLogger
6 | Prettier.TestLogger
7 | PrettierTestLogger
8 | 1.1.1
9 | saintedlama
10 | dotnet;test;logger;xunit
11 | Prettier formatting for your dotnet core tests. Tested with xunit.
12 | https://github.com/saintedlama/prettiertestlogger
13 | https://github.com/saintedlama/prettiertestlogger
14 |
15 | build
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | build/netstandard2.0
25 | true
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/test/HumanizedTestlogger.Tests/bin/Debug/netcoreapp2.1/HumanizedTestlogger.Tests.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}/test/HumanizedTestlogger.Tests",
16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17 | "console": "internalConsole",
18 | "stopAtEntry": false,
19 | "internalConsoleOptions": "openOnSessionStart"
20 | },
21 | {
22 | "name": ".NET Core Attach",
23 | "type": "coreclr",
24 | "request": "attach",
25 | "processId": "${command:pickProcess}"
26 | }
27 | ,]
28 | }
--------------------------------------------------------------------------------
/src/PrettierTestLogger/LogEntryBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text.RegularExpressions;
5 | using Microsoft.VisualStudio.TestPlatform.ObjectModel;
6 |
7 | namespace PrettierTestLogger
8 | {
9 | public class LogEntryBuilder
10 | {
11 | public LogEntry BuildLogEntry(TestResult testResult)
12 | {
13 | var testResultDisplayNameParts = testResult.DisplayName.Split('.').ToList();
14 |
15 | if (testResult.DisplayName.Contains(' '))
16 | {
17 | // Assume that tests that contain spaces are already formatted
18 | return new LogEntry
19 | {
20 | TestClass = testResultDisplayNameParts[0],
21 | Test = String.Join(".", testResultDisplayNameParts.Skip(1)),
22 | Outcome = testResult.Outcome,
23 | DurationMs = (int)testResult.Duration.TotalMilliseconds,
24 | };
25 | }
26 |
27 | if (testResultDisplayNameParts.Count < 2)
28 | {
29 | // This is a best effort try if things go wrong
30 | return new LogEntry
31 | {
32 | TestClass = Format(testResult.DisplayName),
33 | Test = Format(testResult.DisplayName),
34 | Outcome = testResult.Outcome,
35 | DurationMs = (int)testResult.Duration.TotalMilliseconds,
36 | };
37 | }
38 |
39 | // Take the last two parts
40 | var test = testResultDisplayNameParts[testResultDisplayNameParts.Count - 1];
41 | var testClass = testResultDisplayNameParts[testResultDisplayNameParts.Count - 2];
42 |
43 | return new LogEntry
44 | {
45 | TestClass = Format(testClass),
46 | Test = Format(test),
47 | Outcome = testResult.Outcome,
48 | DurationMs = (int)testResult.Duration.TotalMilliseconds,
49 | };
50 | }
51 |
52 | private string Format(string test)
53 | {
54 | if (String.IsNullOrWhiteSpace(test))
55 | {
56 | return test;
57 | }
58 |
59 | if (test.Contains('_'))
60 | {
61 | return String.Join(" ", test.Split('_').Select(FirstLetterToLower));
62 | }
63 |
64 | var replacedAbbrevations = Regex.Replace(test, "[A-Z]{2,}", (match) => " " + match.Value, RegexOptions.Compiled).TrimStart();
65 |
66 | return Regex.Replace(replacedAbbrevations, "[A-Z][a-z]+", (match) => " " + FirstLetterToLower(match.Value), RegexOptions.Compiled).TrimStart();
67 | }
68 |
69 | private static string FirstLetterToLower(string text)
70 | {
71 | if (String.IsNullOrWhiteSpace(text))
72 | {
73 | return text;
74 | }
75 |
76 | return Char.ToLowerInvariant(text[0]) + text.Substring(1);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/PrettierTestLogger.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A6B75EB0-3AE6-4AC1-A9C2-BF79BDA363B2}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrettierTestLogger", "src\PrettierTestLogger\PrettierTestLogger.csproj", "{2C37D368-240C-44AE-BBD9-1E5627E3E1E1}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8E1DCA29-4320-44FC-9BA2-A51A3874600D}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrettierTestLogger.Tests", "test\PrettierTestLogger.Tests\PrettierTestLogger.Tests.csproj", "{46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Debug|x64 = Debug|x64
18 | Debug|x86 = Debug|x86
19 | Release|Any CPU = Release|Any CPU
20 | Release|x64 = Release|x64
21 | Release|x86 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Debug|x64.ActiveCfg = Debug|Any CPU
30 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Debug|x64.Build.0 = Debug|Any CPU
31 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Debug|x86.ActiveCfg = Debug|Any CPU
32 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Debug|x86.Build.0 = Debug|Any CPU
33 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Release|x64.ActiveCfg = Release|Any CPU
36 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Release|x64.Build.0 = Release|Any CPU
37 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Release|x86.ActiveCfg = Release|Any CPU
38 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1}.Release|x86.Build.0 = Release|Any CPU
39 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Debug|x64.ActiveCfg = Debug|Any CPU
42 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Debug|x64.Build.0 = Debug|Any CPU
43 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Debug|x86.ActiveCfg = Debug|Any CPU
44 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Debug|x86.Build.0 = Debug|Any CPU
45 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Release|Any CPU.Build.0 = Release|Any CPU
47 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Release|x64.ActiveCfg = Release|Any CPU
48 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Release|x64.Build.0 = Release|Any CPU
49 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Release|x86.ActiveCfg = Release|Any CPU
50 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D}.Release|x86.Build.0 = Release|Any CPU
51 | EndGlobalSection
52 | GlobalSection(NestedProjects) = preSolution
53 | {2C37D368-240C-44AE-BBD9-1E5627E3E1E1} = {A6B75EB0-3AE6-4AC1-A9C2-BF79BDA363B2}
54 | {46350E5F-9446-4FA8-8D1E-F71F5D7EFF9D} = {8E1DCA29-4320-44FC-9BA2-A51A3874600D}
55 | EndGlobalSection
56 | EndGlobal
57 |
--------------------------------------------------------------------------------
/src/PrettierTestLogger/TestLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.VisualStudio.TestPlatform.ObjectModel;
4 | using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
5 | using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
6 |
7 | namespace PrettierTestLogger
8 | {
9 | [FriendlyName(FriendlyName)]
10 | [ExtensionUri(ExtensionUri)]
11 | public class TestLogger : ITestLogger
12 | {
13 | public const string ExtensionUri = "logger://Microsoft/TestPlatform/PrettierTestLogger/v1";
14 | public const string FriendlyName = "prettier";
15 |
16 | private List LogEntries { get; set; }
17 | private LogEntryBuilder Builder { get; set; }
18 |
19 | public void Initialize(TestLoggerEvents events, Dictionary parameters)
20 | {
21 | LogEntries = new List();
22 | Builder = new LogEntryBuilder();
23 |
24 | events.TestResult += TestResultHandler;
25 | events.TestRunComplete += TestRunCompleteHandler;
26 | }
27 |
28 | public void Initialize(TestLoggerEvents events, string testRunDirectory)
29 | {
30 | LogEntries = new List();
31 | Builder = new LogEntryBuilder();
32 |
33 | events.TestResult += TestResultHandler;
34 | events.TestRunComplete += TestRunCompleteHandler;
35 | }
36 |
37 | public void TestResultHandler(object sender, TestResultEventArgs e)
38 | {
39 | LogEntries.Add(Builder.BuildLogEntry(e.Result));
40 | }
41 |
42 | public void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
43 | {
44 | var orderedByTestClass = new Dictionary>();
45 |
46 | foreach (var logEntry in LogEntries)
47 | {
48 | if (!orderedByTestClass.ContainsKey(logEntry.TestClass))
49 | {
50 | orderedByTestClass[logEntry.TestClass] = new List();
51 | }
52 |
53 | orderedByTestClass[logEntry.TestClass].Add(logEntry);
54 | }
55 |
56 | var foregroundColor = Console.ForegroundColor;
57 | Console.OutputEncoding = System.Text.Encoding.UTF8;
58 |
59 | foreach (var entry in orderedByTestClass)
60 | {
61 | Console.WriteLine();
62 | Console.ForegroundColor = ConsoleColor.DarkGray;
63 | Console.WriteLine($"{entry.Key}");
64 |
65 | foreach (var logEntry in entry.Value)
66 | {
67 | Console.Write(" ");
68 | PrintTestOutcome(logEntry.Outcome);
69 | Console.ForegroundColor = ConsoleColor.Gray;
70 | Console.Write(logEntry.Test);
71 |
72 | Console.ForegroundColor = ConsoleColor.Yellow;
73 | Console.Write($" ({logEntry.DurationMs}ms)");
74 | Console.WriteLine();
75 | }
76 | }
77 |
78 | Console.ForegroundColor = foregroundColor;
79 | }
80 |
81 | public static void PrintTestOutcome(TestOutcome testOutcome)
82 | {
83 | switch (testOutcome)
84 | {
85 | case TestOutcome.Passed:
86 | Console.ForegroundColor = ConsoleColor.Green;
87 | Console.Write("✓ ");
88 | break;
89 | case TestOutcome.Failed:
90 | Console.ForegroundColor = ConsoleColor.Red;
91 | Console.Write("✗ ");
92 | break;
93 | case TestOutcome.None:
94 | Console.ForegroundColor = ConsoleColor.Gray;
95 | Console.Write("- ");
96 | break;
97 | case TestOutcome.NotFound:
98 | Console.ForegroundColor = ConsoleColor.Gray;
99 | Console.Write("? ");
100 | break;
101 | case TestOutcome.Skipped:
102 | Console.ForegroundColor = ConsoleColor.Gray;
103 | Console.Write("~ ");
104 | break;
105 | default:
106 | throw new InvalidOperationException($"Test outcome {testOutcome} is not a supported test outcome");
107 | }
108 | }
109 | }
110 | }
--------------------------------------------------------------------------------
/test/PrettierTestLogger.Tests/LogEntryBuilderTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestPlatform.ObjectModel;
3 | using Xunit;
4 |
5 | namespace PrettierTestLogger.Tests
6 | {
7 | public class LogEntryBuilderTests
8 | {
9 | [Fact]
10 | public void Should_Split_And_LowerCase_CamelCased_Test_Names()
11 | {
12 | var builder = new LogEntryBuilder();
13 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.ShouldSplitAndLowerCaseCamelCasedTestNames");
14 |
15 | var logEntry = builder.BuildLogEntry(testResult);
16 | Assert.Equal("should split and lower case camel cased test names", logEntry.Test);
17 | }
18 |
19 | [Fact]
20 | public void Should_Split_And_Lower_Case_Dash_Separated_Test_Names()
21 | {
22 | var builder = new LogEntryBuilder();
23 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.Should_Split_And_Lower_Case_Dash_Separated_Test_Names");
24 |
25 | var logEntry = builder.BuildLogEntry(testResult);
26 | Assert.Equal("should split and lower case dash separated test names", logEntry.Test);
27 | }
28 |
29 | [Fact]
30 | public void Should_Not_Split_CamelCase_If_Dash_Separated_Test_Names_Are_Used()
31 | {
32 | var builder = new LogEntryBuilder();
33 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.Should_Not_Split_CamelCase_If_Dash_Separated_Test_Names_Are_Used");
34 |
35 | var logEntry = builder.BuildLogEntry(testResult);
36 | Assert.Equal("should not split camelCase if dash separated test names are used", logEntry.Test);
37 | }
38 |
39 | [Fact]
40 | public void Should_LowerCase_First_Letter_If_Dash_Is_Used()
41 | {
42 | var builder = new LogEntryBuilder();
43 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.Should_LowerCase_First_Letter_If_Dash_Is_Used");
44 |
45 | var logEntry = builder.BuildLogEntry(testResult);
46 | Assert.Equal("should lowerCase first letter if dash is used", logEntry.Test);
47 | }
48 |
49 | [Fact]
50 | public void Should_Split_And_LowerCase_CamelCased_TestClass_Names()
51 | {
52 | var builder = new LogEntryBuilder();
53 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.ShouldSplitAndLowerCaseCamelCasedTestNames");
54 |
55 | var logEntry = builder.BuildLogEntry(testResult);
56 | Assert.Equal("log entry builder tests", logEntry.TestClass);
57 | }
58 |
59 | [Fact]
60 | public void Should_Split_And_LowerCase_Dash_Separated_TestClass_Names()
61 | {
62 | var builder = new LogEntryBuilder();
63 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.Log_Entry_Builder_Tests.ShouldSplitAndLowerCaseCamelCasedTestNames");
64 |
65 | var logEntry = builder.BuildLogEntry(testResult);
66 | Assert.Equal("log entry builder tests", logEntry.TestClass);
67 | }
68 |
69 | [Fact]
70 | public void Should_LowerCase_First_Letter_If_Dash_Is_Used_For_TestClass_Names()
71 | {
72 | var builder = new LogEntryBuilder();
73 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.Log_EntryBuilder_Tests.ShouldSplitAndLowerCaseCamelCasedTestNames");
74 |
75 | var logEntry = builder.BuildLogEntry(testResult);
76 | Assert.Equal("log entryBuilder tests", logEntry.TestClass);
77 | }
78 |
79 | [Fact]
80 | public void Should_Not_Split_Abbrevations_In_Uppercase()
81 | {
82 | var builder = new LogEntryBuilder();
83 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.ShouldNotSplitABBREVATIONS");
84 |
85 | var logEntry = builder.BuildLogEntry(testResult);
86 | Assert.Equal("should not split ABBREVATIONS", logEntry.Test);
87 | }
88 |
89 | [Fact]
90 | public void Should_Not_Split_Abbrevations_In_Uppercase_Within_Text()
91 | {
92 | var builder = new LogEntryBuilder();
93 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Tests.LogEntryBuilderTests.ShouldNotSplitABBREVATIONSInText");
94 |
95 | var logEntry = builder.BuildLogEntry(testResult);
96 | Assert.Equal("should not split ABBREVATIONS in text", logEntry.Test);
97 | }
98 |
99 | [Fact]
100 | public void Should_Handle_Ticked_Function_Names()
101 | {
102 | var builder = new LogEntryBuilder();
103 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Should handle ticked function names");
104 |
105 | var logEntry = builder.BuildLogEntry(testResult);
106 | Assert.Equal("Should handle ticked function names", logEntry.Test);
107 | }
108 |
109 | [Fact]
110 | public void Should_Handle_Ticked_Function_Names_With_Special_Characters()
111 | {
112 | var builder = new LogEntryBuilder();
113 | var testResult = BuildTestResultFromDisplayName("PrettierTestLogger.Should handle ticked function names with special characters, e.g. these ones");
114 |
115 | var logEntry = builder.BuildLogEntry(testResult);
116 | Assert.Equal("Should handle ticked function names with special characters, e.g. these ones", logEntry.Test);
117 | }
118 |
119 | private TestResult BuildTestResultFromDisplayName(string displayName)
120 | {
121 | return new TestResult(new TestCase { DisplayName = displayName }) {
122 | DisplayName = displayName,
123 | };
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/csharp
3 |
4 | ### Csharp ###
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 | ##
8 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
9 |
10 | # User-specific files
11 | *.suo
12 | *.user
13 | *.userosscache
14 | *.sln.docstates
15 |
16 | # User-specific files (MonoDevelop/Xamarin Studio)
17 | *.userprefs
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | bld/
27 | [Bb]in/
28 | [Oo]bj/
29 | [Ll]og/
30 |
31 | # Visual Studio 2015/2017 cache/options directory
32 | .vs/
33 | # Uncomment if you have tasks that create the project's static files in wwwroot
34 | #wwwroot/
35 |
36 | # Visual Studio 2017 auto generated files
37 | Generated\ Files/
38 |
39 | # MSTest test Results
40 | [Tt]est[Rr]esult*/
41 | [Bb]uild[Ll]og.*
42 |
43 | # NUNIT
44 | *.VisualState.xml
45 | TestResult.xml
46 |
47 | # Build Results of an ATL Project
48 | [Dd]ebugPS/
49 | [Rr]eleasePS/
50 | dlldata.c
51 |
52 | # Benchmark Results
53 | BenchmarkDotNet.Artifacts/
54 |
55 | # .NET Core
56 | project.lock.json
57 | project.fragment.lock.json
58 | artifacts/
59 |
60 | # StyleCop
61 | StyleCopReport.xml
62 |
63 | # Files built by Visual Studio
64 | *_i.c
65 | *_p.c
66 | *_h.h
67 | *.ilk
68 | *.meta
69 | *.obj
70 | *.iobj
71 | *.pch
72 | *.pdb
73 | *.ipdb
74 | *.pgc
75 | *.pgd
76 | *.rsp
77 | *.sbr
78 | *.tlb
79 | *.tli
80 | *.tlh
81 | *.tmp
82 | *.tmp_proj
83 | *_wpftmp.csproj
84 | *.log
85 | *.vspscc
86 | *.vssscc
87 | .builds
88 | *.pidb
89 | *.svclog
90 | *.scc
91 |
92 | # Chutzpah Test files
93 | _Chutzpah*
94 |
95 | # Visual C++ cache files
96 | ipch/
97 | *.aps
98 | *.ncb
99 | *.opendb
100 | *.opensdf
101 | *.sdf
102 | *.cachefile
103 | *.VC.db
104 | *.VC.VC.opendb
105 |
106 | # Visual Studio profiler
107 | *.psess
108 | *.vsp
109 | *.vspx
110 | *.sap
111 |
112 | # Visual Studio Trace Files
113 | *.e2e
114 |
115 | # TFS 2012 Local Workspace
116 | $tf/
117 |
118 | # Guidance Automation Toolkit
119 | *.gpState
120 |
121 | # ReSharper is a .NET coding add-in
122 | _ReSharper*/
123 | *.[Rr]e[Ss]harper
124 | *.DotSettings.user
125 |
126 | # JustCode is a .NET coding add-in
127 | .JustCode
128 |
129 | # TeamCity is a build add-in
130 | _TeamCity*
131 |
132 | # DotCover is a Code Coverage Tool
133 | *.dotCover
134 |
135 | # AxoCover is a Code Coverage Tool
136 | .axoCover/*
137 | !.axoCover/settings.json
138 |
139 | # Coverlet with OpenCover
140 | coverage.opencover.xml
141 |
142 | # Visual Studio code coverage results
143 | *.coverage
144 | *.coveragexml
145 |
146 | # NCrunch
147 | _NCrunch_*
148 | .*crunch*.local.xml
149 | nCrunchTemp_*
150 |
151 | # MightyMoose
152 | *.mm.*
153 | AutoTest.Net/
154 |
155 | # Web workbench (sass)
156 | .sass-cache/
157 |
158 | # Installshield output folder
159 | [Ee]xpress/
160 |
161 | # DocProject is a documentation generator add-in
162 | DocProject/buildhelp/
163 | DocProject/Help/*.HxT
164 | DocProject/Help/*.HxC
165 | DocProject/Help/*.hhc
166 | DocProject/Help/*.hhk
167 | DocProject/Help/*.hhp
168 | DocProject/Help/Html2
169 | DocProject/Help/html
170 |
171 | # Click-Once directory
172 | publish/
173 |
174 | # Publish Web Output
175 | *.[Pp]ublish.xml
176 | *.azurePubxml
177 | # Note: Comment the next line if you want to checkin your web deploy settings,
178 | # but database connection strings (with potential passwords) will be unencrypted
179 | *.pubxml
180 | *.publishproj
181 |
182 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
183 | # checkin your Azure Web App publish settings, but sensitive information contained
184 | # in these scripts will be unencrypted
185 | PublishScripts/
186 |
187 | # NuGet Packages
188 | *.nupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 |
214 | # Visual Studio cache files
215 | # files ending in .cache can be ignored
216 | *.[Cc]ache
217 | # but keep track of directories ending in .cache
218 | !*.[Cc]ache/
219 |
220 | # Others
221 | ClientBin/
222 | ~$*
223 | *~
224 | *.dbmdl
225 | *.dbproj.schemaview
226 | *.jfm
227 | *.pfx
228 | *.publishsettings
229 | orleans.codegen.cs
230 |
231 | # Including strong name files can present a security risk
232 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
233 | #*.snk
234 |
235 | # Since there are multiple workflows, uncomment next line to ignore bower_components
236 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
237 | #bower_components/
238 |
239 | # RIA/Silverlight projects
240 | Generated_Code/
241 |
242 | # Backup & report files from converting an old project file
243 | # to a newer Visual Studio version. Backup files are not needed,
244 | # because we have git ;-)
245 | _UpgradeReport_Files/
246 | Backup*/
247 | UpgradeLog*.XML
248 | UpgradeLog*.htm
249 | ServiceFabricBackup/
250 | *.rptproj.bak
251 |
252 | # SQL Server files
253 | *.mdf
254 | *.ldf
255 | *.ndf
256 |
257 | # Business Intelligence projects
258 | *.rdl.data
259 | *.bim.layout
260 | *.bim_*.settings
261 | *.rptproj.rsuser
262 |
263 | # Microsoft Fakes
264 | FakesAssemblies/
265 |
266 | # GhostDoc plugin setting file
267 | *.GhostDoc.xml
268 |
269 | # Node.js Tools for Visual Studio
270 | .ntvs_analysis.dat
271 | node_modules/
272 |
273 | # Visual Studio 6 build log
274 | *.plg
275 |
276 | # Visual Studio 6 workspace options file
277 | *.opt
278 |
279 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
280 | *.vbw
281 |
282 | # Visual Studio LightSwitch build output
283 | **/*.HTMLClient/GeneratedArtifacts
284 | **/*.DesktopClient/GeneratedArtifacts
285 | **/*.DesktopClient/ModelManifest.xml
286 | **/*.Server/GeneratedArtifacts
287 | **/*.Server/ModelManifest.xml
288 | _Pvt_Extensions
289 |
290 | # Paket dependency manager
291 | .paket/paket.exe
292 | paket-files/
293 |
294 | # FAKE - F# Make
295 | .fake/
296 |
297 | # JetBrains Rider
298 | .idea/
299 | *.sln.iml
300 |
301 | # CodeRush personal settings
302 | .cr/personal
303 |
304 | # Python Tools for Visual Studio (PTVS)
305 | __pycache__/
306 | *.pyc
307 |
308 | # Cake - Uncomment if you are using it
309 | # tools/**
310 | # !tools/packages.config
311 |
312 | # Tabs Studio
313 | *.tss
314 |
315 | # Telerik's JustMock configuration file
316 | *.jmconfig
317 |
318 | # BizTalk build output
319 | *.btp.cs
320 | *.btm.cs
321 | *.odx.cs
322 | *.xsd.cs
323 |
324 | # OpenCover UI analysis results
325 | OpenCover/
326 |
327 | # Azure Stream Analytics local run output
328 | ASALocalRun/
329 |
330 | # MSBuild Binary and Structured Log
331 | *.binlog
332 |
333 | # NVidia Nsight GPU debugger configuration file
334 | *.nvuser
335 |
336 | # MFractors (Xamarin productivity tool) working folder
337 | .mfractor/
338 |
339 | # Local History for Visual Studio
340 | .localhistory/
341 |
342 |
343 | # End of https://www.gitignore.io/api/csharp
--------------------------------------------------------------------------------