How to unit test ML.NET prediction? - ml.net

I have a ML.NET project deployed as a web api like this - https://learn.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/serve-model-web-api-ml-net
How do I mock the PredictionEnginePool, MLContext or the PredictionEngine in xUnit or any unit test framework?

Have you looked at the tests for ML.NET? MLContext is shown in those examples.
https://github.com/dotnet/machinelearning/tree/master/test
PredictionEnginePool (I don't believe is shown), but it is not a special construct that can't be tested. I would test the FileLoader and being able to test from remote locations if you have to.

Related

How to write unit test for Ebean in play framework

I have an application based on play framework scala version 2.11.1.
There are couple of methods for which I want to add unit tests. These methods have direct calls to database through Ebean.
I tried with this link to use mocki-ebean in order to mock these calls. But the import was unsuccessful
I tried with powermock as well. but it requires to setup in-memory ebean server for mock calls. But that is also deprecated to setup in-memory server for unit testing.
Any idea what could be the next direction?

Do I need a unit-testing framework if I'm already using Cypress in a Vue.js app?

When scaffolding a new project with the Vue.js CLI, it offers a choice of both unit-testing and E2E-testing frameworks.
Unit-testing functionality is perfectly adequate in Cypress. My question, then: is there an advantage to using a distinct unit-testing framework if I'm already using Cypress?
There is a third-party adapter made by a Cypress contributor here called cypress-vue-unit-test(along with unit-test adapters for other popular frameworks).
You should check that out and see if it meets your needs over, say, Jest
From this tutorial about unit testing vuejs, some Jest advantages over Cypress are:
Built in code coverage
Snapshot testing
Module mocking utilities
Also see repo for vue-test-utils

How to write unit tests for server side Meteor code?

I have some server side code -- meteor methods and simple backend helpers -- that I would like to test. I've read the documentation testing with Meteor, but I am having a hard time connecting the documentation to my very simple use case. Can someone share with me how they've tested a meteor method or a simple backend JS function?
For instance, let's say you have some server method in, some_methods.js
function someHelper() {
// does lots of cool stuff
};
Meteor.methods({
'user/update' (userProperties) {
// updating some user properties
someHelper();
}
})
We have developed unit and integration tests for our open source application called RadGrad (https://radgrad.org).
For details on how we do unit and integration testing, please see:
https://www.radgrad.org/docs/developer-guide-testing.html
Here is an example of a unit (server-side only) test:
https://github.com/radgrad/radgrad/blob/master/app/imports/api/career/CareerGoalCollection.test.js
And here is an example of an integration (client + server) test:
https://github.com/radgrad/radgrad/blob/master/app/imports/api/career/CareerGoalCollection.methods.app-test.js
We do not have extensive UI tests; you'll need to use something like Selenium for that. UI testing in Meteor is no different from UI testing for any other web app.

How to unit test my Google OpenID consumer app?

My web app is a Google OpenID consumer (with Attribute Exchange and OAuth Extension) and I need to write some unit test for it [edit: to test the unit that is responsible to interact with google].
The problem is that default OpenID login procedure needs user interaction (entering user/pass) which is not possible in unit test.
Do you have any idea how can I solve this problem and unit test my OpenID consumer app?
(I prefer not to run my own OpenID provider.)
You need to use a remote controlled browser for this. Selenium was made for this use case.
(indeed they are called functional tests then).
Search on Google for the best way to integrate selenium tests into your web framework.
If I understand you want to test your all application and not just "unit test" it.
The actual test framework depends on the technology your application is using. For example there are many UI and web automation tools that can do what you want.
You should also unit test your core functionality or at least write several integration tests that work against an actual Openid provider but instead of running the entire application just test the functionality of the class (if you're using language that has classes) to make sure it can get the b.
I would also write a couple of unit tests that call a fake provider to test how your code behaves in case of error, connection problems and plain vanilla responses.

unit testing sync framework

We have built a custom provider for the microsoft sync framework. How would you go about unit testing it or would you not bother with the unit testing and focus on integration tests?
I have had some success using Moq to help write unit tests for a custom provider. Unfortunately the Sync Framework hasn't been designed to make testing easy.