When fighting on towers or ramparts Break tests are taken on the unmodified Leadership of the unit. Ranks and standards have no effect on the test, so it is the side who suffered the most wounds in a combat who has to take the Break test. The only thing that affects a unit's Leadership in a Break test is the higher Leadership of the character leading them, or their General being within 12". Note that the number of wounds caused in close combat will not modify the Leadership score.
These rules apply for all fighting on the ramparts and towers, including assaults by siege towers, troops scaling the walls with ladders, etc.
Note that troops (such as Skeletons) who suffer extra casualties due to losing rounds of combat also lose one model for every wound they lost the combat by.
If both sides suffer the same number of casualties, then the combat is a draw and no tests are taken by either side. No other factors, such as Musicians, affect the result. As the chances of a regiment breaking are less than usual, battles inside castles tend to last longer. This makes assaults bloody and dangerous affairs - just as they are in real life.
A unit that is charged in the courtyard while it still has models on the ramparts or inside a tower may not claim a bonus for any extra ranks. The unit is considered to be too disorganised to take advantage of this rule.