Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve test framework #21

Open
neocotic opened this issue Nov 3, 2017 · 0 comments
Open

Improve test framework #21

neocotic opened this issue Nov 3, 2017 · 0 comments

Comments

@neocotic
Copy link
Owner

neocotic commented Nov 3, 2017

The current test setup includes a lot of repetition. While this does ensure that the code is thoroughly tested, it would be good to reduce some of this repetition in order to speed up the build process.

Initially, I think a lot could be said for adding more structure to the test descriptors. I'd especially like to separate tests for convert methods with tests for convertFile.

We also need to add tests for the CLI. I think these should also be kept separate from the API methods so that we can fine grain the tests to target the CLI. We need to cover all 3 flows for the CLI as well (i.e. files, STDIN -> STDOUT, STDIN -> filename), but we should be able to reuse the same tests. All options should be covered by these tests. The CWD should be set based on whether or not the test is "core" (i.e. defined in convert-svg-test-helper).

For example;

{
  "api": {
    "convert": {
      "failure": [
        {
          "name": "...",
          "file": "...",
          "options": {},
          "message": "..."
        }
      ],
      "success": [
        {
          "name": "...",
          "file": "...",
          "options": {},
          "message": "..."
        }
      ]
    },
    "convertFile": {
      "failure": [
        {
          "name": "...",
          "file": "...",
          "options": {},
          "message": "..."
        }
      ],
      "success": [
        {
          "name": "...",
          "file": "...",
          "options": {},
          "message": "..."
        }
      ]
    }
  },
  "cli": {
    "failure": [
      {
        "name": "...",
        "args": [],
        "file": "...",
        "stdin": false,
        "stdout": false,
        "message": ""
      }
    ],
    "success": [
      {
        "name": "...",
        "args": [],
        "file": "...",
        "stdin": false,
        "stdout": false,
        "message": ""
      }
    ]
  }
}

It might also be good to only run a specified number of success and/or failure tests against the methods on API, since this is much slower than those on Converter (as these tests share an Converter instance which avoids lots of Chromium instances being created and destroyed).

I realize that these changes might make the JSON a bit more noisy, but it should make it easier to manage. We could even consider splitting the above into multiple files, if it would help.

I'm not sure if it should fall under this issue, but I'd also like to replace our fixture images to some created by us. I'm not sure about the origin of these images, to be honest, as I took them from svg2png which was my inspiration for the original convert-svg-to-png package, released under WTFPL. Since these are technically published by convert-svg-test-helper, however, I'd feel more comfortable owning them. The standard.svg is an exception, which I grant permission to use, however, even then I would like to use completely impartial images that serve the unique purpose of testing these packages.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant