Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test Isjson in MXUnit

I am working on the MxUnit test frame work for CFML. In it, I want to check whether the return value of a function is a valid JSON or not. Currently I am using:

assertEquals(True,IsJSON(userEventItems),'The return must be json');

Is there any MXUnit function to check the assert is a JSON or not, like assertIsQuery() in MXUnit?

like image 274
Uthandu Murugan.M Avatar asked Jul 08 '14 14:07

Uthandu Murugan.M


People also ask

What does unit test do with JSON Schema?

Unit tests are suited to asserting static code behaviour so if your JSON schema specifies rules, the assertion that a unit test does is: Assert that your code validated the JSON Schema and rejected it if invalid. Any behaviour your code should do with valid JSON data scenarios.

How to test JSON code with our tool?

How to Test JSON Code with Our Tool? After opening this JSON checker, paste or type the JSON code in the input field. You can also upload a JSON file stored on your device or enter a URL to fetch JSON. After that, click the “Check JSON” button.

How to check json syntax for bugs?

JSON checker is a web-based tool that will help you know that your JSON code is according to the standard syntax and free from all bugs. You can use this JSON syntax checker tool to restructure your JSON code or discard any unnecessary elements from the code.

What is a JSON checker?

A JSON checker is an online tool that enables you to test and analyze your JSON code. You can use this tool to ensure that your JSON code has an adequate structure and contains no errors. How to Check JSON by URL?


1 Answers

According to the MXUnit built-in assertions page there is not a function. Your best bet is to test the function the way you are or by using the assertTrue() function

assertTrue(isJSON(userEventItems), 'The return must be json');
like image 90
Matt Busche Avatar answered Oct 01 '22 23:10

Matt Busche