Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,413
Community Members
 
Community Events
168
Community Groups

Possible to mock Jira data in unit tests?

Edited

Is there any sort of unit test fixture (besides integration tests) that allow me to create users, issues, and the like in order to create test data in memory for quick and efficient unit testing without waiting for a Jira instance to start?

I'm implementing test fixture mock data manually, such as a test fixture that instantiates a new ApplicationUser or new CustomField, in order to create dummy data for unit testing my Jira plugin (java) backend. Doing so let's me prototype without slowly testing and debugging against a Jira dev server. Each of these Jira data classes mentioned above is an interface with 20 - 50 methods that must be implemented - quite a lot of code! Also, the implementation details I am dangerously guessing, such as how id and name values are set for each class following patterns I detect from REST API calls (e.g. custom field ids seem to start with "customfield_").

I'm happy with my test fixtures - they work, but it's a lot of code and I figured someone else must have done this before enough times to share a fixture? The benefit is developer efficiency with lightning fast unit tests. Starting Jira server locally takes my puny laptop a couple of minutes, then navigating pages can even take 10 - 20 seconds each ;)

 

I should clarify too - I know how to "mock" (with mockito, Junit) but that is not what I'm asking. Mocks still need to return some kind of data, which is ultimately an Issue, CustomField, or some other Jira data and that is what I'm looking to automate the creation of for testing purposes.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events