wiki:UNPLANNED_UNIT_TEST_FIX_R0
Last modified 16 years ago Last modified on 06/27/09 13:11:14

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=UNPLANNED_TEST_FIX_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

Automatic tests need to be improved. Latest Hudson build reports 288 test failures out of 962 tests.

Task requirements

  • Revise the current unit tests
  • Remove any useless test cases (for more, see implementation idea).
  • Make as much as possible tests / demos to work. This includes improving the source if tests report problems.
  • Writing new tests is not required for this revision, since it is too much effort.

Task result

Removed useless tests, others - passing.

Implementation idea

  • Read about how to write good unit tests, PLATFORM_STANDARDS_AUTO_TESTS for documented convensions for testing and "Code smells" in the internal backlog. Look also at the available demos.
  • Describe what needs to be removed, what will be repaired and what tests need to be written during the next revision.
  • Use FakeModuleRegistry where you need to use extension points.

PLATFORM_STANDARDS_AUTO_TESTS

How to demo

Run all the available tests (through Eclipse, right click sophie2-platform, run as.., maven test).

Design

  • While refactoring tests, look for the following things:
    • Each test must have setUp() and tearDown methods, containing at least super.setUp() and super.tearDown().
    • Tests should be UnitTestBase or IntegrationTestBase
    • All resources needed for tests should be placed in the /src/test/resources folder of the module where the test is in
    • Remove testing of obvious things
    • Repair fake JavaDoc
    • Where ither modules are needed, use FakeModuleRegistry.start(). In this case, make the class extend IntegrationTestBase. Look specifically at the modules ewhich have to be started, this is a common mistake.
    • Take care for "TODO: refactor" things.
    • Remove "fail('not implemented')" methods.
    • Refactor any "try{fail();} catch(Throwable){}" statements, since they are useless: if expected Exception, change to catch(Exception); If expected AssertionError, change to catch(Throwable){if (e instanceof AssertionFailedError) fail();} Fix the errors that will appear after refactoring them.
    • Either refactor commented tests, or delete them.
    • Look for the correct place of each test - if incorrect, fix it.
    • Fix the assertEquals and assertSame arguments: first should be expected, then actual.
  • Here is a list of the current modules and what has to be changed there :
org.sophie2.base.boundrefactor
org.sophie2.base.commonsrefactor
org.sophie2.base.connectivitynothing - no tests
org.sophie2.base.dialogsDialogManagerTest must be DialogManagerDemo, it should run
org.sophie2.base.halosrefactor
org.sophie2.base.layoutBaseLayoutDemo is actualy a test; needs to refactor
org.sophie2.base.medianothing - no tests
org.sophie2.base.menusrefactor
org.sophie2.base.model.bookthoroughly refactor/delete GroupTest, review the others.
org.sophie2.base.model.resourcesnothing - OK
org.sophie2.base.model.textnothing - the demo is OK
org.sophie2.base.persistencemany try-catch mistakes, refactor
org.sophie2.base.sceneDelete SceneTest2, revire the demo.
org.sophie2.base.skinsnothing - no tests
org.sophie2.base.visualnothing - OK
org.sophie2.corerefactor
org.sophie2.core.modularityreview - add super.setUp() to setUp methods
org.sophie2.core.mvcreview - Decide whether no view should not be handled (TestDemo2)
org.sophie2.extra.func.annotationsnothing - OK
org.sophie2.extra.func.embeddednothing - no tests
org.sophie2.extra.func.pdfnothig - OK
org.sophie2.extra.func.printnothing - no tests
org.sophie2.main.app.commons rename AppViewUnitTest to AppViewTest, make it an integration test. Thoroughly refactor BookViewUnitTest. Move AudioContentViewTest and VideoContentViewTest to org.sophie2.main.func.media, refactor ContentViewTest, review FrameAddUndoViewTest, fix "catch(Throwable e)" statements, remove any "fail('not implemented')" methods.
org.sophie2.main.app.halosnothing - no tests
org.sophie2.main.app.layoutnothing - no tests
org.sophie2.main.app.menusMake WindowMenuTest integration, decide whether to delete it. Refactor FileMenuTest, move SystemTestBase to org.sophie2.main.app.commons/src/main.java
org.sophie2.main.app.modelMove BackgroundStyleUnitTest, BorderStyleUnitTest, FrameAddUndoTest and FrameUnitTest to org.sophie2.base.model.book, refactor them. Remove BookLegacyTest, review the rest.
org.sophie2.main.dialogs.inputnothing - no tests
org.sophie2.main.func.confignothing - no tests
org.sophie2.main.func.filenothing - no tests
org.sophie2.main.func.helpnothing - no tests
org.sophie2.main.func.imagerefactor
org.sophie2.main.func.linksnothing - OK
org.sophie2.main.func.medianothing - no tests
org.sophie2.main.func.resourcesnothing - no tests
org.sophie2.main.func.serversnothing - no tests
org.sophie2.main.layout.mydoggyrename MyDoggyLayoutDemo to test, since it is not a demo. Make it integration test, add the needed modules and refactor the failing cases.
org.sophie2.main.layout.vldockingthoroughly refactor
org.sophie2.main.media.fobsdelete all
org.sophie2.main.persistence.r1refactor (or delete)
org.sophie2.main.persistence.r2nothing - no tests
org.sophie2.main.scene.joglnothing - no tests
org.sophie2.main.scene.simplenothing - OK
org.sophie2.main.skin.alternativenothing - no tests
org.sophie2.main.ws_connectornothing - no tests
org.sophie2.server add setUp() and tearDown() methods, review
org.sophie2.server.connectoradd setUp() and tearDown() methods, review.
org.sophie2.server.persistenceRemove default values of type "new Date()", add setUp() and tearDown() methods.

Implementation

org.sophie2.base.bounddone [2404], [2459]
org.sophie2.base.commonsdone [2405]
org.sophie2.base.dialogs nothing has been done
org.sophie2.base.halos[2469]: not all tests pass yet.
org.sophie2.base.layout[2467]
org.sophie2.base.menusnothing has been done
org.sophie2.base.model.book [2472], GroupTest seems to be failing only on my computer, so it was not deleted.
org.sophie2.base.persistence[2473], still a lot tests do not pass.
org.sophie2.base.scene[2475] The demo actually shows just 2 lines of text, maybe it doesn't work.
org.sophie2.corenothing has been done
org.sophie2.core.modularity[2476]
org.sophie2.core.mvcnothing has been done.
org.sophie2.main.app.commons [2491] Did not have time to refactor BookViewUnitTest and AppLogicSystemtest. AudioContentViewTest and VideoContentViewTest deleted.
org.sophie2.main.app.menus[2505] needs a lot more.
org.sophie2.main.app.model [2498], [2501] BackgroundStyleUnitTest and BorderStyleUnitTest also deleted
org.sophie2.main.func.image [2497] needs more to be done.
org.sophie2.main.layout.mydoggy [2499] Now it starts, but half of the cases do not pass. Not enough time.
org.sophie2.main.layout.vldockingnothing has been done here
org.sophie2.main.media.fobs fixed by peko/nenko
org.sophie2.main.persistence.r1nothing has been done here
org.sophie2.server.persistence [2503]

Conclusions:

  • base,dialogs, base.menus, core, core.mvc, app.menus and layout.vldocking need to be done in the next revision
  • legacy modules like persistence.r1 and server.persistence should be decided whether to delete or to refactor the tests
  • many modules have not a single test.
  • all suppressWarnings("all") clauses must be removed.
  • JavaDoc must be fixed.

Merged to the trunk in changeset [2549]. --meddle

  • Final result for this revision: 156 tests fail out of 946.

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)