assertj / assertj/assertj-swing

Provide tooling to work with 3rd party libraries where the components are not named

Offen
#256 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
121
Forks
52
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I work a lot with 3rd party software where the UI has not been well designed and components generally do not have a 'name' attribute set, and that makes the matching code quite verbose, or sometimes impossible and I have to resort to reflection to access the components.

I've raised a PR https://github.com/assertj/assertj-swing/pull/255 which addresses this by providing a mechanism to set the name of components. It works as follows:

**Use the field name where possible. e.g.**

`private JTextField myText; // Set the name to be 'myText'`

**For anonymous fields, use a unique generated name. e.g.**

```
public void createComponents(){
add(new JTextField()); // Set the name to be 'JTextField-1'
add(new JTextField()); // Set the name to be 'JTextField-2'
}
```

**Optionally allow overwriting the names of fields. This is useful where the components have been given unsuitable or identical names.**

```
public void createComponentsBadly(){
textField1.setName("text1");
...
textField2.setName("text1");
}
```

**Optionally allow only using generated names. This is useful when the code has been obfuscated and the field names do not provide any meaning, or when the field names are confusing**

```
private JTextField a; // Set the name to be 'JTextField-1'
private JTextField b; // Set the name to be 'JTextField-2'
private JTextField combo1; // Set the name to be 'JTextField-3'
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginnen Sie mit der Durchsicht von Pull Request #255, den der Issue als vorgeschlagenen Einstiegspunkt für die Benennung von Komponenten identifiziert. Prüfen Sie, wie aus Feldern abgeleitete Namen, generierte Namen, das Überschreiben und der Modus „nur generiert“ behandelt werden, und betrachten Sie die Beispiele in diesem Issue als Abschlusskriterien.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
desktop, testing
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.