Creating a new issue with in Junit test case

hitesh bachanna April 6, 2014

I have a method to test which accept the issue, so i need to create a issue from with junit.I use the code below.

but ComponentAccessor.getIssueFactory() always return NULL with i run the test case.

How do i fix this.

MutableIssue issueObject;

IssueFactory issueFactory = ComponentAccessor.getIssueFactory();

ProjectManager projectManager = ComponentAccessor.getProjectManager();

ConstantsManager constantsManager = ComponentAccessor.getConstantsManager();

VersionManager versionManager = ComponentAccessor.getVersionManager();

issueObject = issueFactory.getIssue();

issueObject.setProject(projectManager.getProject(new Long(10200)));

issueObject.setIssueType(constantsManager.getIssueType("1"));

issueObject.setSummary("Test Issue");

issueObject.setReporter(UserUtils.getUser("admin"));

issueObject.setAssignee(UserUtils.getUser("admin"));

issueObject.setPriorityId(constantsManager.getPriorityName("1"));

issueObject.setDescription("Test description");

issueObject.setAffectedVersions(EasyList.build(versionManager.getVersion(new Long(10000)), versionManager.getVersion(new Long(10001))));

issueObject.setFixVersions(EasyList.build(versionManager.getVersion(new Long(10002))));

issueObject.setComponents(EasyList.build(projectManager.getComponent(new Long(10000)), projectManager.getComponent(new Long(10001))));

1 answer

1 accepted

1 vote
Answer accepted
Boris Georgiev _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2014

ComponentAccessor can be used only within the container, and will not work if you run a test like a normal JUnit test. You've got two options

hitesh bachanna April 9, 2014

Thank you I will look into wired tests

Suggest an answer

Log in or Sign up to answer