Skip to content

Write proper unit tests and integration tests #20

@frgomes

Description

@frgomes

Related: #19

IMHO, one of the major deficiencies of actix-web documentation and codebase is that examples may not be self-contained, being clean enough and straighforward enough for newcomers into the library. By "self contained" I mean: "copy from the browser, paste into two files: Cargo.toml and main.rs ... fire cargo and it works."

Writing an end-to-end, real world application, containing reasonable unit tests and integration tests would potentially eradicate this deficiency.

Also, since Actix 2.0 now employs async/await, several examples from the documentation website are just outdated and so, if you are a newbie and copy/paste the example... it will take you a number of hours until you realise that you were simply misguided.

In my case in particular, I've struggled a lot to write a proof of concept which looks like code in production. Examples in the documentation are incomplete (they are just snippets of code), not exercising real world scenarios, which render them sometimes almost useless... apart from the syntax they introduce or some mechanics they illustrate.

I had difficulties finding an example which "just works", which does something so mundane: a simple client code (using actix-web client, not anything else!) which sends a post request containing some JSON and receives some other JSON as response. There's no such example containing unit tests and integration tests (which just work!) as far as I know and, in order to build one, I had to invest a lot of time and effort digging into the code base of a number of repositories.

Then, finally the coin dropped after a number of hours: it does not work because I'm using Actix 2.0 but trying documentation from the website which assumes Actix 1.0.

So, once again: Writing proper unit tests and integration tests in a context of a real world application is a must. Ideally, employing Actix 2.0 as #19 suggests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions