API testing with Newman - How to set up?

Hi,

I’m building a small project that uses GitHub Actions to Build an ASP.NET Core web app.

Building a release artifact and then uploading it in a job works without problems. In the next job I want to download the artifact, run the production app “in the background” and test the running app with Newman (Postman CLI).

Now my question is, how can I achieve that?

I’m not super experienced in CI/CD or docker.

My approach was to try to run the app in the background with “path_to_executable &” and then execute the tests with “newman …”.

This “works” but the problem is that whatever I run in the next step after the one with “path_to_executable &” will just hang. So, I suppose that using background jobs is not the way to go…

Cheers

There are two Gitub actions for you to upload and download artifacts.  For more information, you could refer to this document: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/persisting-workflow-data-using-artifacts#uploading-build-and-test-artifacts 

And there is an action for Newman https://github.com/marketplace/actions/newman-action

For your scenario: Run the production app “in the background” and test the running app with Newman (Postman CLI).

How did you do that in your local machine? Through command?

This “works” but the problem is that whatever I run in the next step after the one with “path_to_executable &” will just hang. 

Can you share your current workflow yml content here? 

On my local machine I can run the app in one terminal window and execute the tests in a different terminal window.

If I would have to do it in one window I could let the app run in background with an added “&” in the end. Then I wouldn’t lose shell access for executing the tests. So I thought this would be a viable startegy in this case.

But it doesn’t seem to work that way.

I am not familar with Newman, can you share your workflow yml here? Which command do you use to run your app?  Which operating system do you use? Windows, Linux or MacOs? What’s the error message you got?