Unit Tests in Server-Side Swift API

I’ve shared my first experiences about backend development in Swift in my previous blog post. This is the follow-up post. I’ll talk about Unit Tests in Swift.


  • Swift accepts only one executable file for the app. We need to split app and library to make it testable. Because testing requires the separate executable file.
  • main.swift file is the main executable for app. LinuxMain.swift file is the main executable for tests.
  • To split them, we’ll create two targets. One target is the library which will consist of all our code. The other one is the app which will be dependent on the library.
  • Do not forget to add ~Tests suffix for your test folders and test files.
  • LinuxMain.swift file must be under the Tests directory.
  • Create a static variable inside test classes and use it as a parameter while calling testCase() method in LinuxMain.swift file.

Continue reading →


HTTP methods & Database Operations in Server-Side Swift API

dotswift-2017-35After deciding to join more conferences this year, the very first one was dotSwift. It was held in a great old theater in Paris. It was a half day conference but it was better than I guessed. There were good talks about backend development in Swift. After hearing a lot about that and great performance of Swift, I decided to give it a try. And here comes my first experiences step by step. Continue reading →