Unit Testing Azure Function with Change Feed Trigger [closed] - unit-testing

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to write a unit test for an Azure Function with Change Feed Trigger.
Is it possible to trigger the function using document db emulator?
or
Should I call onto the function directly?
e.g., FunctionClass.Run(documents, null);
Also, is there any example on creating unit test for azure function?
I wasn't able to find any examples for similar cases.
Thanks

Unit testing means testing code in isolation, without dependencies on things like DB emulators.
So yes, just use your unit testing framework of choice and call Run directly, mocking any internal dependencies if needed.
You can find a couple examples in this repository.

Related

Can you write a unit test for a unit test? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Kind of a meta question, but I was wondering if there would ever be cases where writing a unit test for a unit test would make sense.
You don't have to write a test for that, generally its considered Mutation Testing.
Mutation Testing is a type of software testing in which certain statements of the source code are changed/mutated to check if the test cases are able to find errors in source code. The goal of Mutation Testing is ensuring the quality of test cases in terms of robustness that it should fail the mutated source code.
From Guru99
There's a few well known examples,
PIT for Java
MytPy for Python
Stryker looks like its the one for Javascript.
You could write you own tests that mutate your code itself, but its sensible to use OSS projects and help contribute to them if theres any unique needs given the complexity of the area. You don't want to have to own your own mutating framework either and all the maintance with that.

How to run multiple simulations inside containers programmatically? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am developing a website that runs a simulation given a user-submitted script. I tried to follow some Online Judge architectures, but in my case, I need to send user input and receive the output in realtime, like a simulation.
I tried Kubernetes Jobs, but isn't seems so easy to communicate with the container, especially if I need a Kubernetes client on the language that I am working.
So, my question is: Given this scenario, what is the best approach to orchestrate multiple containers with interactive I/O programmatically?
*Obs.: I am not worrying about security yet.
Please take a look at the design of the spark operator:
https://github.com/GoogleCloudPlatform/spark-on-k8s-operator
That has a somewhat similar design to what you’re targeting. Similarly, Argo Workflow is another example:
https://github.com/argoproj/argo

(How) Do you test your dependencies in your unit-tests? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Should you include testing external dependencies in your unit-tests, eg. not mocking the objects in the dependency but actually creating an instance in your unit-test as to ensure some third party didn't do something stupid like creating a BC-break in a patch release. If so, how do you do this? I can assume that automatically instantiating external code could lead to serious security vulnerabilities.
So after some great comments from #Nkosi I have come to the conclusion that this should not be a part of your unit-test suite. However to correctly test against deficiencies in external dependencies, integration tests should be set-up.
While looking into integration testing I came across a great answer about the balance between unit-tests and integration tests on StackExchange: https://softwareengineering.stackexchange.com/questions/208458/when-should-i-write-integration-tests#answer-208465

how to implement mount function in c/c++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I,m suppose to write a client/server program which mount a directory from the server into client hierarchy. What I have to do is, instead of using linux mount function, implement a method in c.c++ that works like mount function. I did a lot of googling on the net but can't find any good tutorial or document that could help. I will be very grateful if you help me and give me some advice, suggestion or introduce a tutorial/document as a starting point.
Your question is a bit vague. If this is an assignment, it could be about several things:
Implementing a filesystem (FUSE would probably be the simplest place to start).
Just emulating the calls, and defining your own e.g. ls, cd etc. for educational purposes, and bringing in the data from the server.
Implementing a tool like mount, possibly using the mount() system call.

How can I determine what percentage of Github projects contain unit tests? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm working on a presentation about unit testing and TDD. One statistic I'd like to share is the percentage of Github projects that contain unit tests. Is this data available somewhere?
If not, is it possible to obtain through a Github API? I was considering a simple file-based approach based on project type (see if a Java project has any files ending in Test.java, or spec.rb for Ruby), but I've never used their API and don't know how feasible this is.
I don't think there's any API to provide you with that information.
Or at least not without browsing the entire set of repositories, which would not be practical anyway. You might want to suggest the github staff to conduct such a survey themselves, but that will be up to them :)
Grab the list of Java repositories from the Github API (use search and the language parameter), then clone each repository, look for Test.java or whatever and collect your results. I don't think there's a way of doing this without cloning each project though.