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

Documentation for result of test-var-query #728

Open
marcomorain opened this issue Nov 12, 2021 · 4 comments
Open

Documentation for result of test-var-query #728

marcomorain opened this issue Nov 12, 2021 · 4 comments

Comments

@marcomorain
Copy link

marcomorain commented Nov 12, 2021

I've been working on improving the test infrastructure in Calva, and I'm currently trying to integrate closer with Cider's test middleware.

There is no documentation that I can find for the shape of the result returned from test-var-query.

Returns

:results A map of test run data.
:status Either done or indication of an error

Where is the best place to find out what is returned? Are there docs somewhere, or is the code the best place to look?

@vemv
Copy link
Member

vemv commented Nov 12, 2021

Probably I'd look into cider.nrepl.middleware.test + cider.nrepl.middleware.test-test directly

For example this is the init state:

(reset! current-report {:summary {:ns 0 :var 0 :test 0 :pass 0 :fail 0 :error 0}
:results {} :testing-ns nil :gen-input nil}))

Hope it helps!

@bbatsov
Copy link
Member

bbatsov commented Nov 22, 2021

@marcomorain I guess we never documented this properly, so we should change this. The tests are good starting point and I'm thinking it'd be nice to have more documentation about each of the ops, besides the basic one generated from the descriptor. E.g. something like https://nrepl.org/nrepl/0.8/usage/misc.html#code-completion

@marcomorain
Copy link
Author

marcomorain commented Dec 16, 2021

I've come across a strange issue related to this:


<- received
{
  'gen-input': [],
  id: '13',
  results: {
    'sample-project.core-test': {
      'some-new-var': [
        {
          actual: '(2)\n',
          context: [],     <---- array, not a string
          diffs: [ [Array] ],
          expected: '1\n',
          file: 'core_test.clj',
          index: 0,
          line: 8,
          message: '',
          ns: 'sample-project.core-test',
          type: 'fail',
          var: 'some-new-var'
        }
      ]
    }
  },
  session: '7cc0b066-a90a-4285-b455-a99f84fc6ce2',
  summary: { error: 0, fail: 1, ns: 1, pass: 0, test: 1, var: 1 },
  'testing-ns': 'sample-project.core-test'
}

When a test is run that doesn't contain a testing form, the context data returned from cider-nrepl is an empty array, rather than a string or null, which is what I would expect.

@marcomorain
Copy link
Author

When there is a testing form, context is a string:

<- received
{
  'gen-input': [],
  id: '17',
  results: {
    'sample-project.core-test': {
      'this-will-fail': [
        {
          actual: '(a)\n',
          context: 'that something works',   <------- string
          diffs: [ [Array] ],
          expected: 'a\n',
          file: 'core_test.clj',
          index: 0,
          line: 13,
          message: '',
          ns: 'sample-project.core-test',
          type: 'fail',
          var: 'this-will-fail'
        },
        {
          context: 'that something works',  <------- string
          index: 1,
          message: '',
          ns: 'sample-project.core-test',
          type: 'pass',
          var: 'this-will-fail'
        }
      ]
    }
  },
  session: '7cc0b066-a90a-4285-b455-a99f84fc6ce2',
  summary: { error: 0, fail: 1, ns: 1, pass: 1, test: 2, var: 1 },
  'testing-ns': 'sample-project.core-test'
}

@bbatsov bbatsov added the docs label Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants