January 28th, 2019 | by Marek Borowski

Automatic Testing of Web Applications and Popular Frameworks

Table of contents

All software product development specialists at least once have found out how easy it is to destroy the look and performance of half of the application, even so, the last changeset was about changes in this second, theoretically disconnected half. Unfortunately, this is the nature of the malice of inanimate objects that you have to live with. Test engineers can help with that and this is the post about their work and tools dedicated to automatic testing of web applications.

Writing automatic testing for web applications doesn’t differ that much from traditional source code writing, because, similarly to an application, automatic tests are created with the help of programming languages like C# or Python. A test engineer or ‘software developer in tests’, as they’re also called, have to pick the right language, IDE, framework to develop the tests in and the driver – a tool for translating the code to the specific actions run by a browser.

Driver, the Most Important of All Tester’s Tools

The easiest decision in life of every automatic tester is the type of driver, which is the tool for the communication between the IDE and the browser. The easiest, because on the list of relevant tools there is only one of them: Selenium Web Driver (SWD). SWD is unrivaled on the market, probably due to its proliferation; there are versions compatible with all important browsers out there and for running automatic tests in the background, without the need to open up a browser’s window and the need for watching the running process. Aside from the freedom of tool picking for displaying the test, Selenium gives us the same freedom when it comes to picking the language in which a test’s script is going to be made of.

Personally I can recommend the work with only one browser – Chrome. There is a Selenium version for it, called ChromeDriver.

Read also: When to Choose the Go Programming Language for Your Software Project?

Available Programming Languages for Automatic Testing of Web Applications

If you have ever worked with the code and know at least one of the popular languages, I have good news – you can use the knowledge in test creation. On the list of Selenium-preferred languages there are, among others, Java, C#, Python, Ruby, PHP, Perl or JavaScript. This set of tremendously different languages can shock at first glance but it should came as no surprise that it’s a great advantage that can be put into the learning of automatic testing. Since you probably already know at least one previously mentioned technologies, the next phase should come easier. The creators of Selenium decided on making available the work with so many languages, so that tests can be written using the same technology as the source code. Thanks to this idea, in spear moments between fixing bugs or adding new functionalities, it’s easy to delegate group of software product developers to write automatic tests. It can be done after a few hours of intensive training as well.

Read also: Is JavaScript on the Run with WebAssembly as a Replacement?

The framework, or the Icing on the Cake

Each of the previously mentioned languages have at least one of the available frameworks for running automatic tests but I’m going to focus on the most popular ones for C# – MSTest, NUnit and xUnit. It’s necessary to add though, that all frameworks differ because of attributes they use or the method of tests configuration. Attributes are necessary for the correct test setup; with them, we are marking classes with tests, tests themselves, a way for launching them and many more. This kind of subtle differences encourages to do experiments. You can figure out which tool is the most useful to you.

MSTest

One of the oldest and slowly fading framework used for automatic testing. It became a legend because of one thing: complicated and tough configuration. On many blogs dedicated to software development and application testing, we can find developers’ relations that went through a correct attributes and configurability file config. Spoiler alert – it’s a challenge. But to even encourage you a little I have to mention that it has some benefits as well. In comparison to other frameworks – huge technical documentation and full integration with IDE – Visual Studio.

NUnit

As popular as MSTest, NUnit is an open-source tool for beginning your journey with testing. It’s easy to manage and there is a twin version for JAVA, distributed under the name Junit. The next and a very serious advantage of this framework is its adaptation to all languages supported by Microsoft .NET

Read also: When .NET Framework is the Best Choice for Application Development and Why?

xUnit

The team responsible for NUnit decided to simplify automatic testing even more and for that, they created another and free tool – xUnit. This growth in popularity framework doesn’t bow to previously mentioned NUnit and allow for the creation in many programming languages like C#, F#, VB.NET, etc. A very big advantage of this language is a number of additional tools, expanded mostly by Microsoft developers, that ease building, launching and analysing the test package.

Read also: C# vs. Go – Which is Better for Your Next Application?

Attributes

[Test][TestMethod][Fact]Marks a test method.
[TestFixture][TestClass]n/aMarks a test class.
[SetUp][Testlnitialize]ConstructorTriggered before every test case.
[TearDown][TestCleanup]|Disposable.DisposeTriggered after every test case.
[OneTimeSetUp][Classl nitialize]ICIassFixture<T>One-time triggered method before test cases start.
[OneTimeTearDown][ClassCleanup]ICIassFixture<T>One-time triggered method after test cases end.
[Ignore(“reason”)][Ignore][Fact(Skip=”reason”)]Ignores a test case.
[Property][TestProperty][Trait]Sets arbitrary metadata on a test.
[Theory][DataRow][Theory]Configures a data-driven test.
[Category(“”)][TestCategory(“”)][Trait(“Category”,””)]Categorizes the test cases or classes

I hope that this brief presentation of automatic testing has encouraged you to perform testing of your own. I also hope you’ll launch an application with less number of bugs, because the aforementioned tools are just the tip of a very big and challenging iceberg.

Read also: .NET vs. Java: Key Differences and Which One is Better?

If you find yourself interested in our company and consider yourself a good match for CSHARK, contact us! If we currently don’t have the right job for you, we will keep your application on file.

Marek Borowski

Software Developer at CSHARK. .NET and React enthusiast, he fell in love with automation testing. During his whole career he has cooperated with financial institutions; previously worked as anti-money laundering specialist. Last two years as banks apps programmer.