High-Quality Automated Tests- Top 10 EditorConfig Coding Styles Part 1

High-Quality Automated Tests- Top 10 EditorConfig Coding Styles Part 1

This is the second article from the new series- High-Quality Automated Tests. In the previous publication, I showed you how to apply coding standards and styles in your .NET tests using EditorConfig. In this one, I am going to share with you some of the coding styles that you need to use. Initially, my idea was to publish all of them in a single post, but since there are a lot, I decided to split them into two parts.

While ago when we were working on the first version of the BELLATRIX test automation framework, I did this research while I was working on a similar feature for our solution.

1. Indent Case Content

CORRECT

bool isEarthRound = false;
// csharp_indent_block_contents = true
if (isEarthRound)
{
    var answerOfUniverse = 42;
}

INCORRECT

// csharp_indent_block_contents = false
if (isEarthRound)
{
    var answerOfUniverse = 42;
}

2. Indent Block Contents

CORRECT

var answerOfEverything = 42;
// csharp_indent_case_contents = true
switch (answerOfEverything)
{
    case 42:
        break;
    case 13:
        break;
}

INCORRECT

var answerOfEverything = 42;
// csharp_indent_case_contents = false
switch (answerOfEverything)
{
    case 42:
        break;
    case 13:
        break;
}

3. Prefer Braces

CORRECT

// csharp_prefer_braces = true:error
if (isEarthRound)
{
    return;
}

INCORRECT

// csharp_prefer_braces = false:error
if (isEarthRound)
    return;

4. Space After Keywords in Control Flow Statements

CORRECT

// csharp_space_after_keywords_in_control_flow_statements = true
if (isEarthRound)
{
}
while (isEarthRound)
{
}

INCORRECT

// csharp_space_after_keywords_in_control_flow_statements = false
if (isEarthRound)
{
}
while (isEarthRound)
{
}

5. Space before Colon in Inheritance Clause

CORRECT

// csharp_space_before_colon_in_inheritance_clause = true
public class SpaceShipOne : Rocket

INCORRECT

// csharp_space_before_colon_in_inheritance_clause = false
public class SpaceShipOne : Rocket

6. Style Conditional Delegate Call

CORRECT

// csharp_style_conditional_delegate_call = true:error
spaceshipOne?.Invoke("98");

INCORRECT

// csharp_style_conditional_delegate_call = false:error
if (spaceshipOne != null)
{
    spaceshipOne("98");
}

7. Style Expression Bodied Accessors

CORRECT

// csharp_style_expression_bodied_accessors = true:error
private int? fuelType;
public int? FuelType
{
    get => this.fuelType;
    set => this.fuelType = value;
}

INCORRECT

// csharp_style_expression_bodied_accessors = false:error
private int fuelType1;
public int FuelType1
{
    get { return this.fuelType1; }
    set { this.fuelType1 = value; }
}

8. Style Expression Bodied Constructors

CORRECT

// csharp_style_expression_bodied_constructors = true:error
public SampleRulesCode() => FuelType = 100;

INCORRECT

// csharp_style_expression_bodied_constructors = false:error
public SampleRulesCode()
{
    FuelType = 100;
}

9. Style Expression Bodied Indexers

CORRECT

// csharp_style_expression_bodied_indexers = false:error
public int this
{
    get { return 42; }
}

INCORRECT

// csharp_style_expression_bodied_indexers = false:error
public int this
{
    get { return 42; }
}

10. Style Expression Bodied Methods

CORRECT

// csharp_style_expression_bodied_methods = true:error
public int CalculateAnswerOfEverything() => 42;

INCORRECT

// csharp_style_expression_bodied_methods = false:error
public int CalculateAnswerOfEverything()
{
    return 42;
}

Summary

I presented to you 10 of my favorites EditorConfig coding styles. Since I have at least ten more, I will create a second part.

Related Articles

High-Quality Automated Tests

High-Quality Code- Naming Classes, Interfaces, Enumerations

In the last articles from the High-Quality Automated Tests we talked about coding styles and various tools that can help you to force them automatically. In thi

High-Quality Code- Naming Classes, Interfaces, Enumerations

High-Quality Automated Tests

Testing for Developers- Isolation Frameworks Fundamentals

In the series we will define the basic terms that every developer needs to know about testing. The purpose is to give all team members a shared understanding of

Testing for Developers- Isolation Frameworks Fundamentals

High-Quality Automated Tests

High-Quality Code- Naming Methods

In the last articles from the High-Quality Automated Tests we talked about coding styles and various tools that can help you to force them automatically. In thi

High-Quality Code- Naming Methods

High-Quality Automated Tests

High-Quality Automated Tests- Consistent Coding Styles Using EditorConfig

This is the first article from a new series of posts called- High-Quality Automated Tests. I firmly believe that all coded tests should be treated with respect

High-Quality Automated Tests- Consistent Coding Styles Using EditorConfig

High-Quality Automated Tests

High-Quality Automated Tests- Top 10 EditorConfig Coding Styles Part 2

This is the third article from the new series- High-Quality Automated Tests. In the first publication, I showed you how to apply coding standards and styles in

High-Quality Automated Tests- Top 10 EditorConfig Coding Styles Part 2

High-Quality Automated Tests

Testing for Developers- Unit Testing Fundamentals

In the series we will define the basic terms that every developer needs to know about testing. The purpose is to give all team members a shared understanding of

Testing for Developers- Unit Testing Fundamentals
Anton Angelov

About the author

Anton Angelov is Managing Director, Co-Founder, and Chief Test Automation Architect at Automate The Planet — a boutique consulting firm specializing in AI-augmented test automation strategy, implementation, and enablement. He is the creator of BELLATRIX, a cross-platform framework for web, mobile, desktop, and API testing, and the author of 8 bestselling books on test automation. A speaker at 60+ international conferences and researcher in AI-driven testing and LLM-based automation, he has been recognized as QA of the Decade and Webit Changemaker 2025.