Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert remaining tests to junit 5 #5394

Merged
merged 28 commits into from
Nov 11, 2019
Merged

Convert remaining tests to junit 5 #5394

merged 28 commits into from
Nov 11, 2019

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Oct 5, 2019

Remove junit4

The database test were the last remaining tests running on junit4


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@Siedlerchr Siedlerchr changed the title [WIP] Convert remaining tests to junit 5 Convert remaining tests to junit 5 Oct 5, 2019
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 5, 2019
Copy link
Member

@matthiasgeiger matthiasgeiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments...

@MethodSource("getTestingDatabaseSystems")
public void testMetaDataChangedEventListener(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMSProcessor dbmsProcessor) throws Exception {

bibDatabase = new BibDatabase();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first three lines are shared between all tests, thus please extract them to the setup method.

public void setUp() throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
this.dbmsConnection = TestConnector.getTestDBMSConnection(dbmsType);
@MethodSource("getTestingDatabaseSystems")
public void setUp(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMSProcessor dbmsProcessor) throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really works, i.e. did you tested that all test methods are invoked correctly? According to the documentation the before/aftereach handlers don't get their parameterized resolved.

Since a test class may contain regular tests as well as parameterized tests with different parameter lists, values from argument sources are not resolved for lifecycle methods (e.g. @beforeeach) and test class constructors.

But this is in a slightly different context. If this method works, then it should also be used in DBMSSynchronizerTest.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I will see if I can test it locally, but otherwise Travis is green and so I thought it's working

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without double chcking (but trying to understand the implications of Tobias' explanation), I would bet that the test use only one database system and not all avaiable.

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 6, 2019
@koppor
Copy link
Member

koppor commented Oct 9, 2019

@Siedlerchr Please double check that the comments at #4260 (comment) are resolved.

@Siedlerchr
Copy link
Member Author

The database tests are the only remaining. I checked it by removing the junit4 dependency. ArchUnit was converted a long time ago.
I will try to find time the next days to look if all tests are excuted

* upstream/master: (40 commits)
  Add test for regular expression pattern
  Snap GitHub ci (#5379)
  Bump src/main/resources/csl-locales from `e89e6b0` to `9785a6e`
  Bump src/main/resources/csl-styles from `36ac1f6` to `6169061`
  Bump mariadb-java-client from 2.4.4 to 2.5.0
  Bump mockito-core from 3.0.0 to 3.1.0
  Bump slf4j-api from 2.0.0-alpha0 to 2.0.0-alpha1 (#5403)
  Remove unnecessary code
  Fix JabFox integration
  Update CHANGELOG.md
  Add hacktoberfest shields.io badge
  Update CHANGELOG.md
  Fix various copy to clipboard issues (#5340)
  Fix 5359: Writing of Editor field is duplicated (#5392)
  Fix exception when merging entries
  Reenable prevcycle (#5385)
  Update deployment.yml
  revert 3fbe0a2
  use submodules to fetch CSL styles properly
  add missing ','
  ...
@Siedlerchr
Copy link
Member Author

Ah for fucks sake, it should have been a clear warning that all tests were green before..
Turned out, they weren't executed... :(

@tobiasdiez
Copy link
Member

Any hope to get this in? At least the fix that the db and fetcher tests are invoked is important.

@Siedlerchr
Copy link
Member Author

I will try to create a woraround for it, e.g. I had the idea of "manually" calling the setup method and the clear method.

# By Tobias Diez (11) and others
# Via GitHub (30) and others
* upstream/master: (70 commits)
  Use Platform.runLater
  Fixes #5485
  Bump com.github.ben-manes.versions from 0.26.0 to 0.27.0
  Bump src/main/resources/csl-styles from `68a697b` to `c3fd4bd`
  Bump byte-buddy-parent from 1.10.1 to 1.10.2
  Bump mariadb-java-client from 2.5.0 to 2.5.1
  Bump classgraph from 4.8.48 to 4.8.52
  Bump org.beryx.jlink from 2.16.0 to 2.16.2
  Updated CHANGELOG.md
  Open entry editor by default on start-up
  Amend the reference to JabRefReferences initialization (#5487)
  Fix for issue 5463 (#5481)
  Rename index.md to README.md
  Fix not on fx thread error for custom entry types
  Refactor to sorted set (#5477)
  Removed a duplicate name (closes #5476)
  Remove unnecessary sort (#5470)
  lint CONTRIBUTING.md (#5473)
  Mark OOSTyle as invalid if no defaultStyle (#5471)
  Fix highlight problem in entry preview
  ...

# Conflicts:
#	build.gradle
@Siedlerchr
Copy link
Member Author

Siedlerchr commented Oct 24, 2019

There are still a lot of failing tests, I guess most is related to the EntryChangedEvent stuff.

* upstream/master:
  New ADS Fetcher (#5501)
  snap: Add browser proxy for confined browser integration (#5512)
  Fix dark theme loading
  Update PreviewViewer.java
  [WIP] Try to fix dark theme path
call clear in setup to ensure empty tables and no leftovers from failures
@Siedlerchr
Copy link
Member Author

For local testing it's sufficient to install mysql or postgres 10.
Only test which are failing are now the Synchronizer things. Somehow an entry is inserted without fields. I don' understand it yet.
testFieldChangedEventListener and testSynchronizeLocalDatabaseWithEntryUpdate

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea where the problem lies...sorry.

src/main/java/org/jabref/model/entry/BibEntry.java Outdated Show resolved Hide resolved
@@ -148,6 +156,8 @@ void testUpdateNewerEntry(DBMSType dbmsType, DBMSConnection dbmsConnection, DBMS
bibEntry.setField(StandardField.YEAR, "1993");

assertThrows(OfflineLockException.class, () -> dbmsProcessor.updateEntry(bibEntry));

clear(dbmsConnection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important that clear is always invoked? I think, if a assert method fails, then an exception is thrown and thus clear is never called. Either move it before assert or use try finally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I addtionally call clear now as first method in setup :-D

@tobiasdiez
Copy link
Member

Any update on this one?

@Siedlerchr
Copy link
Member Author

Did not yet find time to debug it in detail to find out where exactly the entry gets duplicated

* upstream/master: (116 commits)
  New translations JabRef_en.properties (French) (#5564)
  Select newly added jstyle in table to prevent exception (#5556)
  Make entry editor DND behave as specified in settings (#5554)
  Disabled Windows directory picker temporarily
  Disabled Windows directory picker temporarily
  Adding wix script to support jpackage update
  Making importing a single file easier (Issue #5508) (#5513)
  Fix #5551 - Don't remove unwanted characters before first author is selected (#5558)
  Update JabRef_it.properties
  New translations JabRef_en.properties (Vietnamese)
  New translations JabRef_en.properties (Dutch)
  New translations JabRef_en.properties (French)
  New translations JabRef_en.properties (German)
  New translations JabRef_en.properties (Greek)
  New translations JabRef_en.properties (Indonesian)
  New translations JabRef_en.properties (Italian)
  New translations JabRef_en.properties (Japanese)
  New translations JabRef_en.properties (Danish)
  New translations JabRef_en.properties (Norwegian)
  New translations JabRef_en.properties (Polish)
  ...
@Siedlerchr Siedlerchr changed the title Convert remaining tests to junit 5 [WIP ] Convert remaining tests to junit 5 Nov 5, 2019
@Siedlerchr Siedlerchr mentioned this pull request Nov 5, 2019
6 tasks
@tobiasdiez
Copy link
Member

In order to move forward, I've added the database tests to the list of failed tests. Follow-up issue: #5602

@tobiasdiez tobiasdiez merged commit 04015b0 into master Nov 11, 2019
@tobiasdiez tobiasdiez deleted the convertRemainingTest branch November 11, 2019 22:47
@koppor koppor changed the title [WIP ] Convert remaining tests to junit 5 Convert remaining tests to junit 5 Nov 11, 2019
assertEquals(expectedEntry.getField(StandardField.AUTHOR), actualEntries.get(0).getField(StandardField.AUTHOR));
assertEquals("The nano processor1", actualEntries.get(0).getField(StandardField.TITLE).get());
//somehow the field stable is not filled
assertEquals(Collections.singletonList(expectedEntry), actualEntries);
Copy link
Member Author

@Siedlerchr Siedlerchr Nov 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. The test explicitly checks for a changed title! Please revert!

expectedEntry.setField(StandardField.AUTHOR, "Brad L and Gilson");
expectedEntry.setField(StandardField.TITLE, "The micro multiplexer", EntriesEventSource.SHARED);

List<BibEntry> actualEntries = dbmsProcessor.getSharedEntries();
assertEquals(1, actualEntries.size());
assertEquals(expectedEntry.getField(StandardField.AUTHOR), actualEntries.get(0).getField(StandardField.AUTHOR));
assertEquals("The nano processor1", actualEntries.get(0).getField(StandardField.TITLE).get());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here that the title is different @tobiasdiez

@koppor koppor mentioned this pull request Nov 15, 2019
}

testLogging {
// set options for log level LIFECYCLE
events "failed"
events = ["FAILED", "STANDARD_OUT", "STANDARD_ERROR"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koppor just change this lines.
Im only on mobile for the next days without access to a PC 💻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants