Test Automation: How Programming Languages Rate

Was mulling over the C#/Java situation & couldn't find a compelling reason to use C# other than for WhiteBox Testing. It is slaved to M$ OS & ecosystem, meaning that any hardware used as a test fixture is going to have 40G of bloatware & 1000 background services running which doesn't seem efficient or advisable when consistent results are paramount.

Jumping on the web & AutomationPanda.com seems to come to the same conclusion - though has a preference of Python, probably due to it being a little more lightweight. I just can't get with the syntax/format marriage. I'm not a fan of formatting being a part of syntax. I suppose it forces some standardization of coding styles, but who says that standard is the best approach.

Source: https://automationpanda.com/2017/01/21/the-best-programming-language-for-test-automation/


C#: 25-Class get/set

  • using getter/setters allows for logic to be used in the process
  • for gets, null checking can be performed for Singleton Design Patterns or different things can be returned based on state/value.
  • for sets, null checking & data validation can be performed on the incoming values

Object Instantiation with Property Sets

See Also: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers

When an object is instantiated, the values can be set in the same statement

Car myCar = new Car{Type="Honda",Price=15000};



C#: 24-String Interpolation

//String Formatting Syntax
Console.WriteLine("System: {0}, Priority: {1}, Msg: {2}", system , priority, msg);
//String Interpolation
Console.WriteLine($"System: {system}, Priority: {priority}, Msg: {msg}");



C#: 22-Named and Optional Arguments

Optional Arguments

When arguments are given default values, they become optional

constants can be used


    class Logger
        //using Named argument requires static constant variable...
        //..... const is static, so its redundant to use static
        //static string DefaultSystemName = "EmployeeTracker";
        const string DefaultSystemName = "EmployeeTracker";

        //priority type & system that throws log msg
        public static void Log(string msg, string system = DefaultSystemName, int priority=1)
            Console.WriteLine("System: {0}, Priority: {1}, Msg: {2}", system , priority, system);


Named Arguments

Name arguments can be used in cases where a placeholder is needed for multi-argument methods with optional arguments

Subscribe to C#