In NetBeans, right click the file you are creating tests for. Under Tools=>Create Tests, a dialog should come up:
Give it a class name (the automatic one should be fine) and make sure the location is in Test Packages.
Rename each test function to say exactly what it tests, i.e. testSavePatientShouldUsePrivileges or testSavePatientShouldSavePatient
To add in data to be tested for a table, make sure to add a Test-inititalData.xml file into your src/test/resources:
Code Block |
---|
<?xml version='1.0' encoding='UTF-8'?> <dataset> <raxacore<table_patientname_listhere patientfirst_list_id="1" column_name="TestList1value1" description="First Test List" search_query="" date_created="2012-01-01 00:00:00.0" creator="1" retired="false" uuid="68547121-1b70-465d-99ee-c9dfd95e7d30"second_column_name="value2"/> <raxacore<table_patientname_listhere patientfirst_list_id="2" column_name="TestList2value3" description="Second Test List" search_query="" date_created="2012-01-01 00:00:00.0" creator="1" retired="false" uuid="68547121-1b70-465e-99ee-c9dfd95e7d30second_column_name="value4"/> </dataset> |
(NOTE: the src/test/resources folder should automatically come under the heading 'Other Test Resources' – if not, right click your project in Netbeans and choose Reload POM)
In addition, make sure your table mapping .hbm.xml file is defined in the test-hibernate.cfg.xml file:
Code Block |
---|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
">
<hibernate-configuration>
<session-factory>
<mapping resource="TESTTABLEMAPPINGFILE.hbm.xml" />
</session-factory>
<session-factory>
<mapping resource="ANOTHERMAPPINGFILE.hbm.xml" />
</session-factory>
</hibernate-configuration> |
...