Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write proper unit tests and integration tests #20

Open
frgomes opened this issue Jan 1, 2020 · 2 comments
Open

Write proper unit tests and integration tests #20

frgomes opened this issue Jan 1, 2020 · 2 comments

Comments

@frgomes
Copy link

frgomes commented Jan 1, 2020

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.

@frgomes frgomes changed the title Write unit test and integration tests Write proper unit tests and integration tests Jan 1, 2020
@frgomes
Copy link
Author

frgomes commented Jan 1, 2020

I've created a proof of concept which hopefully will have some common real world scenarios, including unit tests and integration tests. It is not intended to replace this repository, but eventually it can be used as a contribution to this repository in future.

https://github.com/frgomes/poc-rust-actix

@shirshak55
Copy link

shirshak55 commented Jan 2, 2020

yep actix 2.0 has examples but not so much proper unit and e2e testing that really creates problem for many people. And yes they have not updated guides but i think API docs is good for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants