Test faliure after introducing a new test case.

What could be the cause of the below error.

OpenmrsTestsTest.shouldHaveTestAnnotationWhenStartingWithShould:101 org.openmrs.propertyeditor.CohortEditorTest#shouldSetTheEditorValueToTheObjectAssociatedWithGivenId does not have the @Test annotation on it even though the method name starts with ‘should’ ==> expected: “true” but was: “false”

This is after introducing a new test case. below is the code.

@Test public void setMessageSender_shouldSetMessageSender() {

	MessageSender messageSender = new MessageSender() {
		
		@Override
		public void send(Message message) throws MessageException {
			// TODO Auto-generated method stub
			
		}
	};
	
	ms.setMessageSender(messageSender);
	
	assertEquals(ms.getMessageSender(), messageSender, SET_MESSAGE_SENDER_ERROR);
	
}

How does your CohortEditorTest look like?

The CohortEditorTest is the same as the one in master. No changes

public class CohortEditorTest extends BasePropertyEditorTest<Cohort, CohortEditor> {

protected static final String COHORT_XML = "org/openmrs/api/include/CohortServiceTest-cohort.xml";

private static final Integer EXISTING_ID = 1;

@Autowired
private CohortService cohortService;

@BeforeEach
public void prepareData() {
	executeDataSet(COHORT_XML);
}

@Override
protected CohortEditor getNewEditor() {
	return new CohortEditor();
}

@Override
protected Cohort getExistingObject() {
	return cohortService.getCohort(EXISTING_ID);
}

}

And how does your BasePropertyEditorTest look like?

this means that you are actually asserting some thing that never exists and you expect it to exist,re -check your MessageSender class

Same as the one in master

abstract class BasePropertyEditorTest<T extends OpenmrsObject, E extends PropertyEditor> extends BaseContextSensitiveTest {

private static final String NON_EXISTING_ID = "999999";

private static final String NON_EXISTING_UUID = "9999xxxx-e131-11de-babe-001e378eb67e";

protected PropertyEditor editor;

/**
 * @return a new property editor instance used in the tests
 */
protected abstract E getNewEditor();

/**
 * @return an existing object for testing set as text by id and uuid
 */
protected abstract T getExistingObject();

/**
 * @return a non existing object uuid for testing set as text
 */
protected String getNonExistingObjectId() {
	return NON_EXISTING_ID;
}

/**
 * @return a non existing object id for testing set as text
 */
protected String getNonExistingObjectUuid() {
	return NON_EXISTING_UUID;
}

@BeforeEach
public void setUp() {
	editor = getNewEditor();
}

@Test
public void shouldSetTheEditorValueToNullIfGivenNull() {
	
	editor.setAsText(null);
	
	assertNull(editor.getValue());
}

@Test
public void shouldSetTheEditorValueToNullIfGivenAnEmptyString() {
	
	editor.setAsText("  ");
	
	assertNull(editor.getValue());
}

@Test
public void shouldSetTheEditorValueToNullIfGivenIdDoesNotExist() {
	
	editor.setAsText(getNonExistingObjectId());
	
	assertNull(editor.getValue());
}

@Test
public void shouldFailToSetTheEditorValueIfGivenUuidDoesNotExist() {
	
	assertThrows(IllegalArgumentException.class, () -> editor.setAsText(getNonExistingObjectUuid()));
}

@Test
public void shouldSetTheEditorValueToTheObjectAssociatedWithGivenId() {
	
	editor.setAsText(getExistingObject().getId().toString());
	
	assertThat(editor.getValue(), is(getExistingObject()));
}

@Test
public void shouldSetTheEditorValueToObjectAssociatedWithGivenUuid() {
	
	editor.setAsText(getExistingObject().getUuid());
	
	assertThat(editor.getValue(), is(getExistingObject()));
}

@Test
public void shouldReturnEmptyStringIfValueIsNull() {
	
	assertThat(editor.getAsText(), is(""));
}

@Test
public void shouldReturnTheObjectIdIfValueIsNotNull() {
	
	editor.setValue(getExistingObject());
	
	assertThat(editor.getAsText(), is(getExistingObject().getId().toString()));
}

}

@herbert24 Rechecking

Are you compiling from commandline? Which version of OpenMRS? What does this command return? mvn -v

Yes am compiling from the command line.

Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f) Maven home: C:\Program Files\apache-maven-3.8.2 Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre Default locale: en_US, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”

The latest version of OpenMRS. Ran git pull --rebase upstream master today

Can you raise a pull request of your local changes?

Here is the pull request TRUNK-5067:Add tests to MessageServiceImpl by WaltonG · Pull Request #3894 · openmrs/openmrs-core · GitHub

On the pull request build checks, are you getting the same error?

Different error. Check below

Error: Tests run: 111, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 10.505 s <<< FAILURE! - in org.openmrs.api.UserServiceTest

204Error: setUserActivationKey_shouldCreateUserActivationKey Time elapsed: 0.488 s <<< FAILURE!

205org.opentest4j.AssertionFailedError: Expected org.openmrs.notification.MessageException to be thrown, but nothing was thrown.

206 at org.openmrs.api.UserServiceTest.setUserActivationKey_shouldCreateUserActivationKey(UserServiceTest.java:1536)

Since you have not yet made significant changes, just discard them using git reset --hard and git clean -df and then run mvn clean install again.